89c0fbe1f6
The deploy pipeline runs from the working tree, so a wave of shipped features
had never been committed. This snapshots git to what's actually running.
SEO impression recovery (live + verified):
- Duplicate /a/{id} now 301-redirect to their canonical twin instead of 404
(a hard 404 silently dropped already-indexed URLs and tanked impressions).
- Dedup representative selection reworked: accepted/serveable -> established
rep (URL stability) -> quality score, so an accepted page never retires to a
rejected rep and an indexed canonical doesn't churn when a newer twin arrives.
- HEAD /a/{id} returns the same status as GET (api_route GET+HEAD) instead of
falling through to the static mount and 404ing.
- `dedup --force-recluster`: cycle-locked, model-free re-cluster to re-apply the
policy to the existing corpus (shared cycle_lock context manager).
- CLI honors GOODNEWS_DB for its default --db (was silently ignored).
Publishing Desk (admin tool to post highlights to X via Web Intents):
- publishing.py queue/rank/handle-resolution; admin UI; full searchable emoji
picker (bundled data, no CDN) for the blurb editor.
Play games + site:
- Bloom (word-wheel), Memory Match, daily ritual set, Zen Den (dev-gated).
- English-only language gate; source prospecting; paywall + dedup hardening.
Tests: full suite green (349). Ignores tightened (node_modules, data/*.db).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
2.8 KiB
Python
77 lines
2.8 KiB
Python
import pytest
|
|
|
|
from goodnews.db import connect, init_db
|
|
from goodnews.sources import (
|
|
list_candidates,
|
|
promote_candidate,
|
|
reject_candidate,
|
|
restore_candidate,
|
|
save_candidate,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def conn():
|
|
c = connect(":memory:")
|
|
init_db(c)
|
|
yield c
|
|
c.close()
|
|
|
|
|
|
def test_save_and_list_candidate(conn):
|
|
cand = save_candidate(conn, "http://x/feed", preview={"acceptance_rate": 0.8, "sampled": 10}, name="X")
|
|
assert cand["status"] == "quarantined"
|
|
rows = list_candidates(conn)
|
|
assert len(rows) == 1 and rows[0]["feed_url"] == "http://x/feed"
|
|
|
|
|
|
def test_re_preview_preserves_curator_status(conn):
|
|
save_candidate(conn, "http://x/feed")
|
|
reject_candidate(conn, list_candidates(conn)[0]["id"])
|
|
# Re-previewing must NOT revive a rejected feed.
|
|
save_candidate(conn, "http://x/feed", preview={"acceptance_rate": 0.9})
|
|
assert list_candidates(conn)[0]["status"] == "rejected"
|
|
|
|
|
|
def test_restore_sends_rejected_back_to_staging(conn):
|
|
save_candidate(conn, "http://x/feed")
|
|
cid = list_candidates(conn)[0]["id"]
|
|
reject_candidate(conn, cid)
|
|
assert list_candidates(conn)[0]["status"] == "rejected"
|
|
# restore → back to staging ('suggested'), re-enters the pending queue
|
|
assert restore_candidate(conn, cid) is True
|
|
assert list_candidates(conn)[0]["status"] == "suggested"
|
|
# restoring a non-rejected candidate is a no-op (only un-rejects)
|
|
assert restore_candidate(conn, cid) is False
|
|
|
|
|
|
def test_promote_creates_inactive_source_and_marks_promoted(conn):
|
|
cand = save_candidate(conn, "http://x/feed", name="Lovely Feed")
|
|
source_id = promote_candidate(conn, cand["id"]) # inactive by default
|
|
|
|
src = conn.execute("SELECT name, active, status FROM sources WHERE id = ?", (source_id,)).fetchone()
|
|
assert src["name"] == "Lovely Feed"
|
|
assert src["active"] == 0 # active-on-approval: not polled until activated
|
|
assert src["status"] == "paused" # status mirrors active — no drift (active=0 ⇒ paused)
|
|
|
|
status = conn.execute("SELECT status FROM source_candidates WHERE id = ?", (cand["id"],)).fetchone()["status"]
|
|
assert status == "promoted"
|
|
|
|
|
|
def test_promote_active_flag(conn):
|
|
cand = save_candidate(conn, "http://y/feed", name="Y")
|
|
sid = promote_candidate(conn, cand["id"], active=True)
|
|
src = conn.execute("SELECT active, status FROM sources WHERE id = ?", (sid,)).fetchone()
|
|
assert src["active"] == 1 and src["status"] == "active" # both set together
|
|
|
|
|
|
def test_promote_unknown_raises(conn):
|
|
with pytest.raises(ValueError):
|
|
promote_candidate(conn, 999)
|
|
|
|
|
|
def test_name_derived_from_url_when_missing(conn):
|
|
cand = save_candidate(conn, "https://news.example.org/rss")
|
|
sid = promote_candidate(conn, cand["id"])
|
|
assert conn.execute("SELECT name FROM sources WHERE id = ?", (sid,)).fetchone()["name"] == "news.example.org"
|