Use the Django test client.
Check the template used. Then, check each item in the template context.
Check any objects are the right ones, or querysets have the correct items.
Check any forms are of the correct class.
Test any template logic: any
for
or
if
should get a minimal test.
For views that handle POST requests, make sure you test both the valid case and
the invalid case.
Sanity-check that your form is rendered, and its errors are displayed.
Why these points? Skip ahead to
Appendix B, and I’ll show how they are sufficient to
ensure that our views are still correct if we refactor them to start using class-based views.
Next we’ll try and make our data validation more friendly by using a bit of client-side
code. Uh-oh, you know what that means…
224
|
Chapter 12: More Advanced Forms