28 lines
993 B
Python
28 lines
993 B
Python
from app.core.config import Settings
|
|
from app.integrations.news_search_client import NewsSearchClient
|
|
|
|
|
|
def test_news_search_client_maps_article_to_candidate() -> None:
|
|
# 新闻搜索结果会先转为候选信号,再交给模型筛选成最终情报。
|
|
client = NewsSearchClient(Settings())
|
|
signal = client._story_to_signal(
|
|
{
|
|
"title": "Show HN: AI agent platform launches",
|
|
"url": "https://example.com/ai-agent-platform",
|
|
"author": "builder",
|
|
"points": 128,
|
|
"num_comments": 24,
|
|
"created_at": "2026-07-08T12:00:00Z",
|
|
"objectID": "123",
|
|
}
|
|
)
|
|
|
|
assert signal is not None
|
|
assert signal.topic == "AI 新闻候选"
|
|
assert signal.source_type == "news"
|
|
assert signal.source_name == "Hacker News"
|
|
assert signal.published_at is not None
|
|
assert signal.published_at.year == 2026
|
|
assert signal.published_at.hour == 20
|
|
assert "128 points" in signal.summary
|