venthrive-api / tests /test_relevance.py
GitHub Actions
Sync from GitHub 路 2026-10-20 19:36 UTC
a32af27
Raw History Blame Contribute Delete
1.23 kB
"""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