Django: Getting Started Transcripts
Chapter: Django ORM and Databases
Lecture: Calling a view in test with the test client

Login or purchase this course to watch this video and the rest of the course contents.
0:18 My second test, tests the book listing view. Like in the tests for the home app. I'm using the built in client to do an http get.
0:27 On line 35, I checked that the result was a good status code and after that I accessed the responses context dictionary.
0:36 This is a handy way of testing a view without looking for snippets of text inside the rendered HTML.
0:42 This contains the same context that the calling view passed to the render shortcut. As the test suites set up only creates one book.
0:51 There should only be one book in the resulting context dictionary. Like test stringify, this test is bookended,
0:59 see what I did there by calls to the print state helper method. Alright, I've got this in place. Let me go run it.


Talk Python's Mastodon Michael Kennedy's Mastodon