feat: 优化周记周期与总结输出

This commit is contained in:
Benature
2026-11-21 00:52:00 +08:00
parent 81b6ff7a39
commit f177a857a5
6 changed files with 110 additions and 30 deletions

View File

@ -14,6 +14,7 @@ from snooper_summary import (
MagpieClient,
SummaryError,
chunk_messages,
clean_model_output,
drop_casual_content,
drop_empty_meeting_section,
escape_obsidian_tags,
@ -116,6 +117,14 @@ def test_sanitize_wikilink_pipes_preserves_table_and_other_text():
)
def test_clean_model_output_discards_think_draft_and_keeps_final_answer():
content = "<think>草稿\n# 重复日报</think>\n# 最终日报\n正文"
assert clean_model_output(content) == "# 最终日报\n正文"
with pytest.raises(SummaryError):
clean_model_output("<think>未闭合草稿")
def test_system_only_private_chat_does_not_require_a_person_name():
row = synthetic_row(chat_type=1, chat_name="", content="[系统消息]")
row.msg_type = 6
@ -1009,17 +1018,27 @@ def test_monday_loads_sunday_and_previous_workday(tmp_path):
assert "【上周最后工作日 2026-10-30】\n周五合成日志" in content
def test_monday_missing_sunday_is_marked_even_with_workday_log(tmp_path):
def test_monday_with_workday_log_is_not_missing_without_sunday(tmp_path):
config = {"summary": str(tmp_path / "{date}.md")}
(tmp_path / "2026-10-30.md").write_text("周五合成日志", encoding="utf-8")
content, previous_missing = load_previous_summary(config, date(2026, 11, 2))
assert previous_missing
assert not previous_missing
assert "【周日 2026-11-01】\n<日志不存在>" in content
assert "周五合成日志" in content
def test_monday_without_sunday_or_workday_log_is_missing(tmp_path):
config = {"summary": str(tmp_path / "{date}.md")}
content, previous_missing = load_previous_summary(config, date(2026, 11, 2))
assert previous_missing
assert "【周日 2026-11-01】\n<日志不存在>" in content
assert "【上周最后工作日 2026-10-30】\n<日志不存在>" in content
def test_previous_workday_skips_custom_holidays_and_weekends():
holidays = {date(2026, 10, 30), date(2026, 11, 1)}