django_satprep
--------------

Simple collection of utilities that make testing Django with nose and twill
easier and happier.

Installation
===========

Plop this somewhere on your Python path.

Using Nose
==========

To use Nose as your Django test runner, in settings.py:

TEST_RUNNER = ‘django_satprep.nose_runner.run_tests’

This means that 'python manage.py test' will use Nose to collect/run tests.

Using Twill
===========

If you're using Nose, you can easily write Twill tests.  django_satprep gives
you a quick setup you can use to talk to your Django project over wsgi.

Here's an example test:


 from nose.tools import *
 from twill import commands as twill
 
 from django_satprep import twill_utils
 
 
 @with_setup(test_utils.setup)
 def test_login():
     """Make sure a user can login from the home page."""
     from django.contrib.auth import models
     user = models.User.objects.create(username='michael',
         email='test@example.com', password='bob', is_active=True)
     user.save()
     twill.go('twill_utils.TWILL_HOME)
     twill.code('200')
     twill.find('My Project')
     twill.find('Sign in')
     twill.follow('Sign in')
     twill.code('200')
     twill.fv('1', 'username', 'michael')
     twill.fv('1', 'password', 'bob')
     twill.submit()
     twill.code('200')
     twill.find('error')
     twill.find('michael')
     user.set_password('bob')
     user.save()
     twill.fv('1', 'password', 'bob')
     twill.submit()
     twill.code('200')
     twill.notfind('error')



Notice that twill is going to twill_utils.TWILL_HOME - by default, this is
http://127.0.0.1:9876.  You can change the port by defining TWILL_WSGI_PORT
in your settings.py.

