Add a Postgres integration test tier and close named coverage gaps #68

Closed
opened 2026-07-18 05:31:31 +00:00 by claude-bot · 2 comments
Contributor

conftest monkey-patches JSONB→JSON and runs on in-memory SQLite
(tests/conftest.py:17-20,58-74), so pg_notify/SSE, JSONB behavior, real
unique-constraint dedup, and timestamptz handling are never exercised.
Zero-coverage modules: api/sse.py, api/media.py, api/location_subs.py
(authz mirrors the tested channel-keyed API — test that layer),
notifiers/discord_bot.py. Add: (1) a small Postgres tier run in CI (F-26) —
sent_alerts dedup under asyncpg, pg_notify→SSE smoke test, channel-delete
SET NULL behavior (F-09); (2) unit tests for named gaps: SPC cross-day
(F-03) and reissuance (F-05) regressions, notifier link-failure injection
(F-15), VTEC parse edge cases + SPC GIF fallback (radar.py:155-522), AI
total-timeout branch (ai_summarizer.py:1086-1090). Also correct CLAUDE.md's
stale "no automated tests" line.

Acceptance criteria:

  • Postgres tier runs in CI and covers dedup + pg_notify + FK behavior
  • Each named gap has at least one test
  • CLAUDE.md testing note corrected

Filed from the 2026-07-17 codebase audit (docs/.internal/report-2026-07-17.md), finding F-29.

conftest monkey-patches JSONB→JSON and runs on in-memory SQLite (tests/conftest.py:17-20,58-74), so pg_notify/SSE, JSONB behavior, real unique-constraint dedup, and timestamptz handling are never exercised. Zero-coverage modules: api/sse.py, api/media.py, api/location_subs.py (authz mirrors the tested channel-keyed API — test that layer), notifiers/discord_bot.py. Add: (1) a small Postgres tier run in CI (F-26) — sent_alerts dedup under asyncpg, pg_notify→SSE smoke test, channel-delete SET NULL behavior (F-09); (2) unit tests for named gaps: SPC cross-day (F-03) and reissuance (F-05) regressions, notifier link-failure injection (F-15), VTEC parse edge cases + SPC GIF fallback (radar.py:155-522), AI total-timeout branch (ai_summarizer.py:1086-1090). Also correct CLAUDE.md's stale "no automated tests" line. **Acceptance criteria:** - [ ] Postgres tier runs in CI and covers dedup + pg_notify + FK behavior - [ ] Each named gap has at least one test - [ ] CLAUDE.md testing note corrected --- _Filed from the 2026-07-17 codebase audit (`docs/.internal/report-2026-07-17.md`), finding F-29._
Author
Contributor

Picking this up as part of v1.1.0 Phase 1 (with #65). Approach: gate the conftest JSONB→JSON monkeypatch on WEATHERBOT_TEST_DB=postgres so the Postgres tier runs as a separate pytest invocation against a real PG (real JSONB/FK/unique-null semantics), selected by a postgres marker; the SQLite suite stays the fast default (addopts = -m "not postgres"). Postgres-tier tests: sent_alerts dedup under asyncpg, pg_notify LISTEN/NOTIFY round-trip (the SSE contract), and channel-delete SET NULL (the authoritative F-09 check SQLite couldn't do). Remaining named unit gaps (VTEC parse edges, SPC GIF fallback, AI total-timeout) added as regular tests; the SPC cross-day/reissuance/notifier-link gaps already got tests in v1.0.2. Will also correct CLAUDE.md's stale "no automated tests" line.

Picking this up as part of v1.1.0 Phase 1 (with #65). Approach: gate the conftest JSONB→JSON monkeypatch on `WEATHERBOT_TEST_DB=postgres` so the Postgres tier runs as a separate pytest invocation against a real PG (real JSONB/FK/unique-null semantics), selected by a `postgres` marker; the SQLite suite stays the fast default (`addopts = -m "not postgres"`). Postgres-tier tests: `sent_alerts` dedup under asyncpg, `pg_notify` LISTEN/NOTIFY round-trip (the SSE contract), and channel-delete `SET NULL` (the authoritative F-09 check SQLite couldn't do). Remaining named unit gaps (VTEC parse edges, SPC GIF fallback, AI total-timeout) added as regular tests; the SPC cross-day/reissuance/notifier-link gaps already got tests in v1.0.2. Will also correct CLAUDE.md's stale "no automated tests" line.
Author
Contributor

Done in #94 (merged to main). Added a Postgres integration tier: the conftest JSONB→JSON monkeypatch is gated on WEATHERBOT_TEST_DB=postgres, new pg_engine/pg_db fixtures build the schema from ORM metadata, and @pytest.mark.postgres tests are excluded from the default SQLite run. Tier covers sent_alerts UNIQUE dedup under asyncpg, dashboard NULL-channel rows not being deduped (documents the gap #57 will close), channel-delete ON DELETE SET NULL (the authoritative F-09 check), and a pg_notify LISTEN/NOTIFY round-trip. Coverage-gap unit tests added for VTEC parsing edges, SPC GIF assembly/fallback, and the AI total-timeout branch. CLAUDE.md's stale "no automated tests" note corrected. Verified on the dev server (Postgres tier 4 passed) and green in CI.

Done in #94 (merged to `main`). Added a Postgres integration tier: the conftest JSONB→JSON monkeypatch is gated on `WEATHERBOT_TEST_DB=postgres`, new `pg_engine`/`pg_db` fixtures build the schema from ORM metadata, and `@pytest.mark.postgres` tests are excluded from the default SQLite run. Tier covers `sent_alerts` UNIQUE dedup under asyncpg, dashboard NULL-channel rows not being deduped (documents the gap #57 will close), channel-delete `ON DELETE SET NULL` (the authoritative F-09 check), and a `pg_notify` LISTEN/NOTIFY round-trip. Coverage-gap unit tests added for VTEC parsing edges, SPC GIF assembly/fallback, and the AI total-timeout branch. CLAUDE.md's stale "no automated tests" note corrected. Verified on the dev server (Postgres tier 4 passed) and green in CI.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/WeatherBot#68
No description provided.