Hardening pass: scheduler backoff, FK cascade, a11y, test safety net
Pre-traffic cleanup from an audit: * Scheduler: poll_due_sources now keys on the last *attempt* (success or failure), not the last success, and scales the wait by the consecutive- failure streak (capped at a day). A failing feed (e.g. Phys.org's HTTP 429s) used to be retried every cycle because it had no successful run; it now backs off and recovers on its own. Extracted due_source_rows() + tests. * FK hygiene: deleting a daily_brief is supposed to cascade to its items, but SQLite enforces foreign keys per-connection — connect() already sets the pragma, so the cascade is correct going forward; added a regression test. (Orphaned items + Phys.org settings were cleaned directly on the live DB.) * a11y: modal/drawer dialogs are now focusable (tabindex), close on Escape (window) and on backdrop click via a target check (dropping the inner stopPropagation handlers). Build is warning-free. * tests: conftest points any un-mocked LLM client at a closed port with a 1s timeout, so an accidental real call fails fast instead of hanging the suite. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_real_llm(monkeypatch):
|
||||
"""Safety net: no test should reach the real arbiter.
|
||||
|
||||
If a test constructs an LLM client from env without mocking, point it at a
|
||||
closed local port with a 1s timeout so the call fails fast instead of
|
||||
hanging on the production 300s timeout (which looks like a stalled suite).
|
||||
Tests that exercise the LLM patch it at the function level, which overrides
|
||||
these env defaults.
|
||||
"""
|
||||
monkeypatch.setenv("GOODNEWS_LLM_BASE_URL", "http://127.0.0.1:1/v1")
|
||||
monkeypatch.setenv("GOODNEWS_LLM_TIMEOUT", "1")
|
||||
monkeypatch.delenv("GOODNEWS_LLM_API_KEY", raising=False)
|
||||
Reference in New Issue
Block a user