diff --git a/data_scrapers/tests/private/conftest.py b/data_scrapers/tests/private/conftest.py index 4771e14..11511b9 100644 --- a/data_scrapers/tests/private/conftest.py +++ b/data_scrapers/tests/private/conftest.py @@ -3,15 +3,15 @@ import pytest from sqlalchemy.orm import Session -from tests.private.database import drop_tables, engine, init_database +from tests.private.database import create_tables, drop_tables, engine, init_database @pytest.fixture(autouse=True) def database(): init_database() + create_tables() yield drop_tables() - engine.dispose() @pytest.fixture diff --git a/data_scrapers/tests/private/database.py b/data_scrapers/tests/private/database.py index 83a5f18..e2b6c41 100644 --- a/data_scrapers/tests/private/database.py +++ b/data_scrapers/tests/private/database.py @@ -1,6 +1,9 @@ from sqlalchemy import Table, create_engine from sqlalchemy_utils import create_database, database_exists +import private.game.model # noqa: F401 +import private.genre.model # noqa: F401 +import private.screenshot.model # noqa: F401 from private.config import setting from private.model import Base @@ -15,8 +18,10 @@ def init_database(): if not database_exists(setting.DATABASE_URL): create_database(setting.DATABASE_URL) + +def create_tables(): Base.metadata.create_all(engine, get_tables(), checkfirst=True) def drop_tables(): - Base.metadata.drop_all(engine) + Base.metadata.drop_all(engine, get_tables())