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 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.