Writing a first round of unit tests
Now, we will write the first round of unit tests. Specifically, we will write unit tests related to the game category class-based views: GameCategoryList
and GameCategoryDetail
. Open the existing games/test.py
file and replace the existing code with the following lines that declare many import
statements and the GameCategoryTests
class. The code file for the sample is included in the restful_python_chapter_04_04
folder, as shown:
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.utils.http import urlencode
from rest_framework import status
from rest_framework.test import APITestCase
from games.models import GameCategory
class GameCategoryTests(APITestCase):
def create_game_category(self, ...
Get Building RESTful Python Web Services 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.