diff --git a/backend/app/core/deps.py b/backend/app/core/deps.py index af29349..b7140a2 100644 --- a/backend/app/core/deps.py +++ b/backend/app/core/deps.py @@ -23,10 +23,12 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]: async def init_db(): """Apply non-destructive schema upgrades before creating missing tables.""" + from importlib import import_module + from app.models import Base - from migrations.versions.20260803_reliability_monitoring import ( - run_reliability_migration, - ) + + migration = import_module("migrations.versions.20260803_reliability_monitoring") + run_reliability_migration = migration.run_reliability_migration async with engine.begin() as conn: await conn.run_sync(run_reliability_migration) diff --git a/backend/tests/test_deps_import.py b/backend/tests/test_deps_import.py new file mode 100644 index 0000000..7d4741b --- /dev/null +++ b/backend/tests/test_deps_import.py @@ -0,0 +1,10 @@ +"""Regression coverage for application dependency module imports.""" + +from pathlib import Path + + +def test_dependency_module_compiles(): + """Database initialization dependencies remain valid Python syntax.""" + module_path = Path(__file__).parents[1] / "app" / "core" / "deps.py" + + compile(module_path.read_text(encoding="utf-8"), str(module_path), "exec")