Files
thejayman77 bfd612eb9b Paywall awareness (#6) + replace-an-article (#7)
- paywall.py: conservative domain-level paywall detection (New Scientist,
  Nature, and common hard/soft paywalls). Never fetches pages — an honest hint.
- API: Article gains a 'paywalled' flag; the brief now leads with a gentle AND
  readable story (paywalled/charged stories stay in the five, just not first).
- New GET /api/replacement returns the next-best readable, unshown article
  (honors mood+prefs via the merged prefs param; gentle=true for hero swaps).
- UI: paywalled cards show 'May need a subscription'; a Replace / 'Find one I
  can read' action (always visible, while tuning actions stay tucked) swaps the
  card for a readable alternative, with a gentle notice when none remain.
- Tests: paywall detection + replacement behavior (77 total).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 00:39:13 +00:00

15 lines
627 B
Python

from goodnews.paywall import is_paywalled
def test_known_paywalls_flagged():
assert is_paywalled("https://www.newscientist.com/article/x")
assert is_paywalled("https://www.nature.com/articles/d41586")
assert is_paywalled("https://news.nature.com/foo") # subdomain
assert is_paywalled("https://www.nytimes.com/2026/05/31/x")
def test_free_domains_not_flagged():
assert not is_paywalled("https://www.theguardian.com/x")
assert not is_paywalled("https://phys.org/news/x")
assert not is_paywalled("https://www.goodnewsnetwork.org/x")
assert not is_paywalled(None)
assert not is_paywalled("")