More specifically, I did not want to mock the Data Store Model objects, since that very quickly turns into mocking hell - you just end up spending three times as much time thinking about mocking than you are about code. Fortunately, after quite a bit of digging, I discovered that Google provides a temporary, in-memory datastore stub, specifically made for unit testing! They also provide stubs for mail, urlfetch and the user service. MAN that is nice!
For this example, I am using:
- App Engine SDK 1.1
- Django Helper r30
- Django 0.97
We will be using the Test Runner provided by Django. Django looks for tests in a number of places, one is tests.py - which it expects to be in same folder as models.py and views.py. To have django run your tests you go:
manage.py test nameofYourApp
The code
models.py
tests.py
views.py
address.html is basically just "{{ form }}" and some HTML.
There ya go. Post any questions as comments, and I will try to answer them!