Archive for October, 2008

TDD with Django. Part 2. Twill tests

Testing of the web projects is very hard. We try to cover all application with unit tests and twill tests. And if we have a lot of javascript, we also make selenium tests.

To use twill tests from the nosetests and Django, we’ve created simple helper to create many tests faster. Here is it:

 # -*- coding: utf-8 -*-
 IP = '127.0.0.1'
 PORT = 8088
 SITE = 'http://%s:%s' % (IP, PORT)

 class TwillMock(object):

    def setup(self):
        '''
        — setup twill virtual web server
        '''
        from django.core.servers.basehttp import AdminMediaHandler
        from django.core.handlers.wsgi import WSGIHandler

        app = AdminMediaHandler(WSGIHandler())
        add_wsgi_intercept(IP, PORT, lambda: app)

Making new test class derived from the TwillMock class make creation of nose twill tests much easier.
Look at the example of such test:

class TestLogin(TwillMock):

    def test_start_page(self):
        """
        Test start_page view
        """
        go(SITE)
        code(200)
        check_links()

    def test_login(self):
        go(SITE + '/accounts/login/')
        code(200)
        show()
        formvalue(1, 'username',  'test1')
        formvalue(1, 'password', 'test1')
        submit()
        code(200)

Django projects version policy

Some weeks ago, Django get his own clear release process : http://docs.djangoproject.com/en/dev/internals/release-process/

I have proposed rules for our team to create Django-projects:

  • We develop using current stable version (1.0, 1.1 or 1.1.4)
  • If security Django release appears (e.g. 1.0.3) every project immediately moves to this release
  • If our project should be released after new “big” Django release or just before (1-2 weeks) , separate branch should be created and project should be tested vs Django beta. After final release, this separate branch becomes master.
  • For special cases, e.g. project is long-tem and cover Django 1.0 and 2.0, which will be incompatible, policy should be discussed additionally.

Now we are using 1.0.X trunk, http://code.djangoproject.com/svn/django/branches/releases/1.0.X/

Do you agree? What policy do you use?

Startuplet — how to start things without budget

Andrey write the post about the idea of startuplets — small startups which should suit for some formal and hard requirements:

  • takes 40 hours of development or less from idea to first user
  • has detailed financial revenue model
  • comes online within 1 calendar month from start
  • gets a paying customer or substantial revenue after 3 months from start
  • profitable after 12 months from start
  • has a well-defined buzz plan

Now we are co-investing and coding for one project which should be the first startuplet:) This is amazing and interesting work.

So, check for updates :)