diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 6d6e4358..56f2e94c 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -16,6 +16,14 @@ from app.main import app from app.core.database import Base, get_db from app.core.admin_database import get_admin_db from app.core.config import settings +# Import every model module so all tables are registered with Base.metadata +# before the test_db fixture calls create_all. app.main imports models lazily +# (inside scheduler functions and route modules), which is fine at runtime +# but leaves the metadata incomplete at fixture-setup time — surfacing as +# "relation X does not exist" errors for any model whose route/scheduler +# hasn't been loaded yet. The `from app import models` form avoids +# shadowing the `app` FastAPI instance imported just above. +from app import models as _models # noqa: F401 # Disable invite code requirement for tests settings.REQUIRE_INVITE_CODE = False