We have a small suite of tests which are run manually by troggle programmers like this:
troggle$ python manage.py test -v 1
The test code is all in troggle/core/TESTS/tests.py.
The test 'test_page_expofile' checks that a particular PDF is being served correctly by the web server and that the resulting page is the correct length of 2,299,270 bytes:
def test_page_expofile(self):
# Flat file tests.
response = self.client.get('/expofiles/documents/surveying/tunnel-loefflerCP35-only.pdf')
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.content), 2299270)
This test suite is part of the django test system which is a very thin layer on top of the standard python library module unittest. One of the things this layer does is to ensure that all the settings are imported correctly, and it sets up a very fast in-memory sqlite database purely for tests. No tests are run with the real expo database.
The tests can be run at a more verbose level by setting the -v 3 flag.
As yet we have no test database set up, so the in-memory database is entirely empty. However we have 'fixtures' in troggle/core/fixtures/ which are JSON files containing dummy data which is used in the more complex tests.
If you want to write some tests and are having trouble finding something which is untested, have a look at the list of url paths in the routing system in troggle/urls.py and look for types of url which do not appear in the test suite checks.