[patch] Additions to TestCase for easy view testing
|Reported by:||Owned by:||Adrian Holovaty|
|Severity:||Keywords:||view client unit testing|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||no||Patch needs improvement:||no|
At work we frequently have testing idioms likes this:
...do database stuff...
response = self.client.get('/some/url/')
check the response status code
check the response template
check the response content
check the response content_type
I'm attaching a patch, with tests, that adds a "check_view" method to TestCase that wraps up the common idiom of checking the status code, the template, the content and the content_type.
In my mind it's somewhat analogous to render_to_response -- it's a shortcut for a common idiom, and it doesn't prevent you from doing more complex/interesting testing with the other assertX methods.