refactor: Phase 3 拆分 generate 流水线并补全测试
提取 collect/formatters/themes 等 pipeline 模块,新增 wecom 分条、RSS、delta、Agent 工作流测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
55
tests/test_agent_workflow.py
Normal file
55
tests/test_agent_workflow.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
|
||||
def test_analyze_trends_parses_json(monkeypatch, isolated_output):
|
||||
import daily.agent_workflow as agent
|
||||
import daily.config as config
|
||||
|
||||
monkeypatch.setattr(config, "OUTPUT_DIR", isolated_output)
|
||||
monkeypatch.setattr(agent, "OUTPUT_DIR", isolated_output)
|
||||
|
||||
monkeypatch.setattr(
|
||||
agent,
|
||||
"llm_chat",
|
||||
lambda system, user: json.dumps(
|
||||
{
|
||||
"headline": "Skills 视频工具升温",
|
||||
"opening": "今日 remotion 相关技能继续走强。",
|
||||
"themes": [{"name": "视频", "summary": "Remotion 生态活跃"}],
|
||||
"top_picks": [],
|
||||
"signals": [],
|
||||
},
|
||||
ensure_ascii=False,
|
||||
),
|
||||
)
|
||||
|
||||
llm_input = {"date": "2026-07-03", "skills_trending": []}
|
||||
trends = agent.analyze_trends(llm_input, date_str="2026-07-03")
|
||||
|
||||
assert trends is not None
|
||||
assert trends["headline"] == "Skills 视频工具升温"
|
||||
assert (isolated_output / "2026-07-03.trends.json").exists()
|
||||
|
||||
|
||||
def test_write_wecom_report_extracts_markdown_block(monkeypatch):
|
||||
import daily.agent_workflow as agent
|
||||
|
||||
monkeypatch.setattr(
|
||||
agent,
|
||||
"llm_chat",
|
||||
lambda system, user: "```markdown\n📰 **早报 · 2026-07-03**\n\n正文\n```",
|
||||
)
|
||||
|
||||
md = agent.write_wecom_report(
|
||||
{"date": "2026-07-03"},
|
||||
{"headline": "test", "opening": "open"},
|
||||
date_str="2026-07-03",
|
||||
time_str="09:30 (UTC+8)",
|
||||
updated="2026-07-02",
|
||||
)
|
||||
|
||||
assert md is not None
|
||||
assert md.startswith("📰")
|
||||
assert "正文" in md
|
||||
Reference in New Issue
Block a user