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 TestCase
class InitialTests(TestCase):
def setUp(self):
self.app = create_app('test_config')
self.test_client = self.app.test_client()
self.app_context...