mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 12:11:46 +08:00
test: add some test cases
This commit is contained in:
@@ -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):
|
||||
|
Reference in New Issue
Block a user