From the course: Building RESTful Web APIs with Django

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Test case for a ListAPIView subclass

Test case for a ListAPIView subclass

From the course: Building RESTful Web APIs with Django

Start my 1-month free trial

Test case for a ListAPIView subclass

- [Instructor] Let's write a test case for the list of products from the API. ProductListTestCase is the name and it also uses the APITestCase. We're going to keep track of the product's count. And we are checking the response for call and get on the products list. And we are asserting that all the pagination fields exist and that they are the right values. And we're checking that the number of products is correct, not only in the count but in the results themselves. Notice that we don't have to check each product, because we are already testing the product serializer in another test case. Now we run the tests and it looks like they all passed.

Contents