Testing views with mock

In this recipe, we will take a look at how to write unit tests. Unit tests are those that check whether individual functions or methods return the correct results. We will look at the likes app and write tests that check whether posting to the json_set_like() view returns a failure response for unauthenticated users and a successful result for authenticated users. We will use Mock objects to simulate the HttpRequest and AnonymousUser objects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset