1
I’m not quite sure why you’re doing all that stuff with resolver
. That’s not really relevant to a unit test; you don’t ever call the view itself, so you’re not testing any of its actual functionality, the only thing you’re testing here is Django’s URL resolver.
Instead, you should use the functionality provided by the test client to actually call your views:
def test_edit_records(self):
response = self.client.get('/edit_records/38/')
self.assertContains(response, 'some data you expect to see in the response')
And you can do the same with the POST:
def test_edit_records_POST(self):
response = self.client.POST('/edit_records/38/', {q:1, w:2})
self.assertTrue(something_about_the_response)
Source:stackexchange.com