08/1: TDD with Django. Part 1
Starting my first big Django-project (Building.ua), I hadn’t know anything about TDD except the fact it is. Project was done but it is very buggy and hard for future develop.
After very productive work with Andrey Khavryuchenko , I’ve learnt his model of tests and now try to add some points to it to make it cover near 100% of the Django application.
All tests in Django-TDD I’d like to divide into parts:
— Unit tests
— Integration and modification tests
— Twill html tests
— Selenium tests
— Other specific tests (e.g. test RTF or PDF output)
Andrey use nosetest in all python projects. And this model is better for me as standard Djando UnitTest derived testrunner. The biggest issue of such model is that you can use one test templates for all your python projects. Second, we use nosetest with coverage plugin which give us very useful metric to know how code is tested.
Unit tests for every new Django model looks like:
— create/edit/delete object of the model
— call unicode() and get_absolute_url() methods
Extensions of the model results appearing new tests in the testscase for this model.
All unit and integration django tests we create as the subclasses of the DbMock class. As a result every test has it’s own clean database and we don’t care about it.
For testing simple html functions and interactions we use Twill. Twill give the possibility to run by the pages, find and fill the forms and check results. Of course, you could use Selenium for this too, but in this case Twill is more cheaper solution.
To run Twill (and Selenium), we create virtual Django WSGI server and connect to it from the tests.
For testing javascript iterations, we use Selenium-RC, which have good python interface. The biggest problem for Selenium tests — is to run this tests on the buildbot servers. The one solution I see — is to setup server with X and set Selenium to run Firefox on this server.
I am planning to write some code in next articles to show our examples for running nose/twill/selenium tests for Django application.
07/27: I've came back
I’ve came back from my vacation to Carpatians. And have some new ideas for posts. The first post about my view of TDD I’ve plan to write in some days.
After I’ve switched my job and start working for the KDS in this January, I faced the problem of regular time tracking of my activity to correctly report all my tasks during the day.
First, I’ve used one the most simple tool — Gedit :) I’ve configured shortcuts to insert time stamps in the text file. The biggest problem for such lazy person as I am was in the making reports which was not very simple — I’ve to open OpenOffice, copy timestamps there, convert time format, sum and analyze where time was lost.
Another problem was in fact that when I was left my workplace I’ve often forgotten to stop tracking of the time.
After recent post of Andriy Khavryuchenko about time tracking I’ve decided to try another tools for time tracking.
I’ve tried GnoTime, but it supposed to be monster for me.
Suddenly I’ve meet notice about Project Hamster. I’ve decided to give it a try and I’m totally surprised!
After a week of using Hamster, I’m in love with such his functions:
Auto generated reports for any day, week, month. Hamster is also divide all tasks by categories and I’m using this function to divide my tasks by projects :)
Hamster auto stops time tracking after 3 (or any other value) minutes of being idle
Very easy start and stop of tracking time.
Always show time tracker with current status in the panel.
And the biggest pleasure for me: now I’m tracking all my activity during the day — starting from the smoking, reading news and finishing with the reviewing of the code, writing the tests and code. And now I see where my time goes!
There are some pictures of the tool from official site, during next days, I’ll add my screenshots.
Applet in panel:
Time report:
Sort activities by categories:
06/22: First post
This blog run on the modified version of the byteflow blog engine. Modification was done to run on the django newforms-admin branch. Some features of the byteflow aren’t fully worked. After I would done with them, I’ll contact byteflow authors and will make public access to the repo of the branch.