2 Commits
Author SHA1 Message Date
peter 921c2bf5a4 test(db): harden the DB lane per code-review (R6 S3)
/code-review high on S3 — 3 low findings, 2 fixed, 1 no-change:
- _db_reachable() now probes via a throwaway engine with connect_timeout=3, so a
  slow/firewalled DATABASE_URL can't hang the whole suite at import (the app engine
  has no connect timeout).
- test_plex_facets sets the "configured" gate flag via monkeypatch (auto-restored)
  instead of poking state._configured_cache in a manual finally — no leak risk, and
  the now-unnecessary mark_configured DB write is dropped.
No change: test_plex_jsonb_normalize copying migration 0060's SQL is deliberate —
migrations must stay self-contained (no app imports) and a shipped migration is
immutable, so there's no real drift to guard against.

Gate: ruff clean; DB lane 176 passed; pure-logic 172 passed / 4 skipped (fast).
2026-07-26 15:09:25 +02:00
peter 4b6bc54aa8 test(db): stand up the DB-backed pytest lane (R6 S3b)
The suite was pure-logic only (R2 S2b deferred the DB lane). Add an opt-in `db`
fixture (tests/conftest.py) that hands a test a real session against an ephemeral
Postgres; schema is built with `alembic upgrade head` (the real prod schema needs
the unaccent extension + unaccent_simple TS config that create_all can't provide,
and this also proves the migration chain applies). Each test starts from a TRUNCATEd
clean DB so tests that COMMIT — the whole point, for R6 S2's transaction work —
don't leak.

backend/docker-compose.test.yml wires an ephemeral tmpfs pg + the test image. When
no Postgres is reachable (a plain `docker run`), the DB tests SKIP and the pure-logic
lane is unchanged: 172 passed, 2 skipped. With the DB: 174 passed.

test_db_lane.py smoke-proves commit round-trip + TRUNCATE isolation. The gate wiring
(siftlode.sh) lands in the ops repo.
2026-07-26 13:47:07 +02:00