Mark backend SQLite request-scoping task done and clean up test fixture

This commit is contained in:
2026-04-06 19:49:29 +02:00
parent 3b58179845
commit 5107ff10d7
2 changed files with 9 additions and 9 deletions

View File

@@ -69,12 +69,12 @@ async def client(test_settings: Settings) -> AsyncClient: # type: ignore[misc]
"""
app = create_app(settings=test_settings)
# Bootstrap the database on app.state so Depends(get_db) works in tests.
# The ASGI lifespan is not triggered by ASGITransport, so we do this here.
# Bootstrap the database schema before making requests. ASGITransport
# does not run the application lifespan, so we create the test SQLite file
# directly rather than relying on startup logic.
db: aiosqlite.Connection = await aiosqlite.connect(test_settings.database_path)
db.row_factory = aiosqlite.Row
await init_db(db)
app.state.db = db
transport: ASGITransport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as ac: