diff --git a/conftest.py b/conftest.py new file mode 100644 index 000000000..b266311a6 --- /dev/null +++ b/conftest.py @@ -0,0 +1,22 @@ +from pytest import fixture + +from app import create_app, db +from test_utils import rename_host_table_and_indexes + + +@fixture +def flask_app_fixture(): + rename_host_table_and_indexes() + + app = create_app(config_name="testing") + + # binds the app to the current context + with app.app_context() as ctx: + # create all tables + db.create_all() + ctx.push() + yield app + ctx.pop + + db.session.remove() + db.drop_all() diff --git a/test_db_model.py b/test_db_model.py index a7522729a..414792850 100644 --- a/test_db_model.py +++ b/test_db_model.py @@ -2,7 +2,6 @@ from app import db from app.models import Host -from test_utils import flask_app_fixture """ These tests are for testing the db model classes outside of the api. diff --git a/test_host_dedup_logic.py b/test_host_dedup_logic.py index 1c9608f90..4820efea1 100644 --- a/test_host_dedup_logic.py +++ b/test_host_dedup_logic.py @@ -4,7 +4,7 @@ from app import db from app.models import Host from pytest import mark -from test_utils import flask_app_fixture + ACCOUNT_NUMBER = "000102" diff --git a/test_utils.py b/test_utils.py index 964f36460..ce50aed37 100644 --- a/test_utils.py +++ b/test_utils.py @@ -1,9 +1,7 @@ import contextlib import os -import pytest import unittest.mock -from app import create_app, db from app.models import Host @@ -33,21 +31,3 @@ def rename_host_table_and_indexes(): for index in Host.__table_args__: if temp_table_name_suffix not in index.name: index.name = index.name + temp_table_name_suffix - - -@pytest.fixture -def flask_app_fixture(): - rename_host_table_and_indexes() - - app = create_app(config_name="testing") - - # binds the app to the current context - with app.app_context() as ctx: - # create all tables - db.create_all() - ctx.push() - yield app - ctx.pop - - db.session.remove() - db.drop_all()