Writing the first round of unit tests

Now, we will write the first round of unit tests. Specifically, we will write unit tests related to the ESRB rating class-based views: EsrbRatingList and EsrbRatingDetail.

Open the tests.py file in the games_service/games folder. Replace the existing code with the following lines that declare many import statements and two functions. The code file for the sample is included in the restful_python_2_08_02 folder, in the Django01/games-service/games/tests.py file:

import pytest 
from django.urls import reverse 
from django.utils.http import urlencode 
from rest_framework import status 
from games import views 
from games.models import EsrbRating 
 
 
def create_esrb_rating(client, description): 
 url = reverse(views.EsrbRatingList.name) ...

Get Hands-On RESTful Python Web Services - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.