Skip to content

Commit c2f23df

Browse files
fix(test): correct Settings() alias usage and mypy union-attr in migration test
Adding a real Postgres service to CI (previous commit) surfaced a real bug: test_unconfigured_dependencies_report_degraded constructed Settings(database_url=None, qdrant_url=None, ...) using the Python attribute names, but Settings has no populate_by_name=True and its fields are aliased (alias="DATABASE_URL" etc.) with extra="ignore" -- so those two kwargs were silently dropped as unrecognized extras, and the settings fell through to the real DATABASE_URL env var instead of the intended None override. This was invisible before because CI had no Postgres server either way, so the env-var fallback also produced "down" by coincidence. Every other Settings(...) construction in the test suite already uses the alias spelling (DATABASE_URL=, JWT_SECRET=, ...); fixed this one call site to match. Also fixed a new mypy union-attr error from the prior commit's _exec_script helper: AsyncConnection.get_raw_connection()'s driver_connection is typed Any | None. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent c93db0e commit c2f23df

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎db/tests/test_schema.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ async def test_forward_then_rollback_restores_baseline() -> None:
354354
async def _exec_script(conn: AsyncConnection, sql: str) -> None:
355355
"""Run a (possibly multi-statement) SQL script via the raw driver connection."""
356356
raw_connection = await conn.get_raw_connection()
357-
await raw_connection.driver_connection.execute(sql)
357+
driver_connection = raw_connection.driver_connection
358+
assert driver_connection is not None
359+
await driver_connection.execute(sql)
358360

359361
engine = create_async_engine(os.environ["DATABASE_URL"])
360362
try:

‎tests/test_health_internals.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class TestEvaluateReadiness:
150150

151151
async def test_unconfigured_dependencies_report_degraded(self) -> None:
152152
"""Unconfigured DATABASE_URL/QDRANT_URL surface as degraded + down."""
153-
settings = Settings(database_url=None, qdrant_url=None, JWT_ISSUER="test-issuer")
153+
settings = Settings(DATABASE_URL=None, QDRANT_URL=None, JWT_ISSUER="test-issuer")
154154
readiness = await health.evaluate_readiness(settings)
155155
assert readiness.status == "degraded"
156156
assert readiness.dependencies == {"postgres": "down", "qdrant": "down"}

0 commit comments

Comments
 (0)