This is the second part of what I started here . You can read the first post of Testing With Python: The Django Way to understand this one. Now where were we? The last time we left at test data. Now we will delve into requests. GET Requests The easiest of your views to test are the ones that only handle GET requests. All you have to do is retrieve the correct item from the database and display the information. Let's use the canonical book/author/publisher example. Suppose we're testing a view that displays the details for a particular book. def test_book_detail(self): testbook = Book.objects.all()[0] url = '/books/id/' + str(testbook.id) response = self.client.get(url) self.assertContains(response, testbook.title) The first thing I want to stress, is that I think it's important that no specific test data is used in the tests. Always try to select objects you're going to use for your tests ...
This is my mindless rambling.