diff --git a/src/backend/tests/conftest.py b/src/backend/tests/conftest.py index e546cdbf85..4b0c1262f8 100644 --- a/src/backend/tests/conftest.py +++ b/src/backend/tests/conftest.py @@ -38,6 +38,7 @@ from app.central import central_crud, central_schemas from app.central.central_schemas import ODKCentralDecrypted, ODKCentralIn from app.config import encrypt_value, settings +from app.db.database import db_conn from app.db.enums import TaskStatus, UserRole, get_action_for_status_change from app.db.models import DbProject, DbTask, DbTaskHistory from app.main import get_application @@ -329,6 +330,10 @@ async def project_data(): @pytest_asyncio.fixture(scope="function") async def client(app: FastAPI, db: AsyncConnection): """The FastAPI test server.""" + # Override server db connection to use same as in conftest + # NOTE this is marginally slower, but required else tests fail + app.dependency_overrides[db_conn] = lambda: db + async with LifespanManager(app) as manager: async with AsyncClient( transport=ASGITransport(app=manager.app),