// base class
class BaseTest(TestCase):
# setup DB
@classmethod
def setUpClass(cls):
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
app.config['DEBUG'] = False
with app.app_context():
# initialize DB
db.init_app(app)
# create DB
def setUp(self):
with app.app_context():
db.create_all()
self.app = app.test_client
self.app_context = app.app_context
class TestPantry(BaseTest):
def test_create_pantry(self):
with self.app() as endpoint:
with self.app_context():
response = endpoint.post('/pantry/Liquids')
self.assertEqual(response.status_code, 200) # returns 404
上述端点在通过邮递员进行测试时有效,但在系统测试中,所有端点均返回404。