How to do it...

To test REST APIs, perform the following steps:

  1. Create a tests.py file in your bulletin_board app, with just the setup and teardown methods, as follows:
# bulletin_board/tests.py
from django.contrib.auth.models import Userfrom django.core.urlresolvers import reversefrom rest_framework import statusfrom rest_framework.test import APITestCasefrom .models import Category, Bulletinclass BulletinTests(APITestCase):    @classmethod    def setUpClass(cls):        super(BulletinTests, cls).setUpClass()        cls.superuser = User.objects.create_superuser(            username="test-admin",            password="test-admin",            email="")        cls.category = Category.objects.create(title="Movies")        cls.bulletin = Bulletin.objects.create(            bulletin_type="searching", category=cls.category, ...

Get Django 2 Web Development Cookbook - Third 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.