test: add obituary headline filtering test
Made-with: Cursor
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from datetime import date
|
from datetime import date
|
||||||
@@ -136,3 +137,31 @@ def test_truncate_to_width_fits_within_budget():
|
|||||||
bbox = draw.textbbox((0, 0), result, font=font)
|
bbox = draw.textbbox((0, 0), result, font=font)
|
||||||
rendered_width = bbox[2] - bbox[0]
|
rendered_width = bbox[2] - bbox[0]
|
||||||
assert rendered_width <= max_width, f"Rendered width {rendered_width} exceeds {max_width}"
|
assert rendered_width <= max_width, f"Rendered width {rendered_width} exceeds {max_width}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_obituary_headlines_filtered():
|
||||||
|
"""Verify the filtering pattern used by publish/issues/scheduler call sites."""
|
||||||
|
class FakeArticle:
|
||||||
|
def __init__(self, title, categories):
|
||||||
|
self.title = title
|
||||||
|
self.categories = json.dumps(categories)
|
||||||
|
|
||||||
|
articles = [
|
||||||
|
FakeArticle("Town Meeting Approves Budget", ["Government"]),
|
||||||
|
FakeArticle("John Smith, 85, beloved teacher", ["Obituaries"]),
|
||||||
|
FakeArticle("Harbor Festival This Weekend", ["Culture"]),
|
||||||
|
FakeArticle("Jane Doe, 92, retired nurse", ["Obituaries"]),
|
||||||
|
FakeArticle("Panthers Win Championship", ["Sports"]),
|
||||||
|
]
|
||||||
|
|
||||||
|
headlines = [
|
||||||
|
a.title for a in articles
|
||||||
|
if "Obituaries" not in json.loads(a.categories)
|
||||||
|
]
|
||||||
|
|
||||||
|
assert len(headlines) == 3
|
||||||
|
assert "John Smith, 85, beloved teacher" not in headlines
|
||||||
|
assert "Jane Doe, 92, retired nurse" not in headlines
|
||||||
|
assert "Town Meeting Approves Budget" in headlines
|
||||||
|
assert "Harbor Festival This Weekend" in headlines
|
||||||
|
assert "Panthers Win Championship" in headlines
|
||||||
|
|||||||
Reference in New Issue
Block a user