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)
esrb_rating_data = {'description': description}
esrb_rating_response = client.post(url...