Spaces:
Running
Running
File size: 1,231 Bytes
a32af27 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | """Unit tests for the keyword pre-filter (news/relevance.py) that gates Groq calls."""
from news.relevance import score
def test_rejects_text_with_no_business_signal():
result = score("Bunk mates fall out over missing snacks at boarding school dormitory")
assert result["is_candidate"] is False
assert result["matched_keywords"] == []
def test_rejects_isolated_incident_with_no_business_angle():
result = score("Aircraft loses contact mid-flight before making emergency landing")
assert result["is_candidate"] is False
def test_accepts_policy_item():
result = score("CBN raises interest rate, forex dealers react")
assert result["is_candidate"] is True
assert "cbn" in result["matched_keywords"]
def test_accepts_funding_item():
result = score("BOI opens new loan scheme for small manufacturers")
assert result["is_candidate"] is True
def test_accepts_weather_item():
result = score("NiMet issues flood warning for Lagos ahead of heavy rainfall")
assert result["is_candidate"] is True
def test_accepts_security_item_with_business_operational_angle():
result = score("Bandits attack causes market shutdown order in Zamfara")
assert result["is_candidate"] is True
|