Five Good Things
@@ -77,9 +137,55 @@
diff --git a/tests/test_filters.py b/tests/test_filters.py
index 8dfda55..37ed47f 100644
--- a/tests/test_filters.py
+++ b/tests/test_filters.py
@@ -4,6 +4,7 @@ from goodnews.filters import (
FilterPrefs,
Pause,
filter_articles,
+ prefs_from_json,
text_matches_avoid_terms,
)
@@ -86,3 +87,37 @@ def test_pause_active_helper():
assert Pause("topic", "health", "2026-06-02T00:00:00Z").active(NOW)
assert not Pause("topic", "health", "2026-05-01T00:00:00Z").active(NOW)
assert not Pause("topic", "health", "garbage").active(NOW)
+
+
+def test_pause_active_tolerates_naive_now():
+ # A naive `now` must not raise an aware-vs-naive comparison error.
+ naive = datetime(2026, 6, 1)
+ assert Pause("topic", "health", "2026-06-02T00:00:00Z").active(naive)
+
+
+# --- forgiving parsing (bad blobs must never break the feed) ---
+
+def test_prefs_from_json_tolerates_garbage():
+ assert prefs_from_json("not json").is_empty()
+ assert prefs_from_json(None).is_empty()
+ assert prefs_from_json("[1,2,3]").is_empty() # wrong shape
+
+
+def test_from_dict_skips_malformed_pauses():
+ prefs = FilterPrefs.from_dict(
+ {
+ "mute_topics": ["health"],
+ "pauses": [
+ {"kind": "topic", "value": "science", "until": "2026-06-02T00:00:00Z"},
+ {"kind": "topic"}, # malformed — missing value/until
+ "garbage", # not even a dict
+ ],
+ }
+ )
+ assert prefs.mute_topics == ["health"]
+ assert len(prefs.pauses) == 1 # only the well-formed pause survives
+
+
+def test_from_dict_ignores_non_string_list_entries():
+ prefs = FilterPrefs.from_dict({"avoid_terms": ["ok", 5, None, "fine"]})
+ assert prefs.avoid_terms == ["ok", "fine"]