test: add some test cases

This commit is contained in:
penzai
2020-02-16 18:03:33 +08:00
parent 7b3f95b41d
commit b798d5e2cc
5 changed files with 237 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ from flask.testing import FlaskClient
from werkzeug.datastructures import Headers
from api.app import create_app
from api.extensions import db
from api.extensions import db, cache
from api.models.acl import User
@@ -75,6 +75,7 @@ def database(app):
def session(database, app):
with app.app_context():
clean_db()
clean_cache()
yield database.session
database.session.rollback()
@@ -91,6 +92,10 @@ def teardown_db():
db.session.bind.dispose()
def clean_cache():
cache.clear()
def clean_db():
"""clean all data but not drop table"""
for table in reversed(db.metadata.sorted_tables):