Writing a first round of unit tests

Now, we will write a first round of unit tests. Specifically, we will write unit tests related to the user and message category resources: UserResource, UserListResource, CategoryResource, and CategoryListResource. Create a new tests sub-folder within the api folder. Then, create a new test_views.py file within the new api/tests sub-folder. Add the following lines, that declare many import statements and the first methods for the InitialTests class. The code file for the sample is included in the restful_python_chapter_08_01 folder:

from app import create_app from base64 import b64encode from flask import current_app, json, url_for from models import db, Category, Message, User import status from unittest import ...

Get Building RESTful Python Web Services now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.