feat: 按自然月回补日报周报和月报
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from datetime import date
|
||||
|
||||
from backfill_summaries import missing_message_dates
|
||||
from backfill_summaries import has_missing_report_tag, missing_message_dates
|
||||
|
||||
|
||||
def test_backfill_skips_empty_days_and_existing_nonempty_summaries(tmp_path):
|
||||
@ -33,3 +33,27 @@ def test_backfill_overwrite_still_skips_days_without_messages(tmp_path):
|
||||
))
|
||||
|
||||
assert days == [date(2024, 6, 2)]
|
||||
|
||||
|
||||
def test_backfill_refreshes_only_tagged_reports_from_requested_date(tmp_path):
|
||||
tagged = tmp_path / "2024-11-27.md"
|
||||
tagged.write_text(
|
||||
"---\ntags:\n- no_previous_weekly\n---\n旧日报", encoding="utf-8"
|
||||
)
|
||||
later = tmp_path / "2024-11-28.md"
|
||||
later.write_text("---\ntags:\n- no_previous_monthly\n---\n旧日报", encoding="utf-8")
|
||||
ordinary = tmp_path / "2024-11-29.md"
|
||||
ordinary.write_text("已有日报", encoding="utf-8")
|
||||
|
||||
days = list(missing_message_dates(
|
||||
date(2024, 11, 27),
|
||||
date(2024, 11, 29),
|
||||
lambda day: True,
|
||||
lambda day: tmp_path / f"{day.isoformat()}.md",
|
||||
refresh_tagged_from=date(2024, 11, 28),
|
||||
))
|
||||
|
||||
assert days == [date(2024, 11, 28)]
|
||||
assert has_missing_report_tag(tagged)
|
||||
assert has_missing_report_tag(later)
|
||||
assert not has_missing_report_tag(ordinary)
|
||||
|
||||
15
tests/test_monthly.py
Normal file
15
tests/test_monthly.py
Normal file
@ -0,0 +1,15 @@
|
||||
from datetime import date
|
||||
|
||||
from snooper_monthly import load_previous_monthly_background
|
||||
|
||||
|
||||
def test_previous_monthly_missing_only_applies_to_first_five_workdays(tmp_path):
|
||||
output = {"monthly": str(tmp_path / "Monthly" / "MsgMYYYY-MM.md")}
|
||||
|
||||
content, missing = load_previous_monthly_background(output, date(2024, 11, 1))
|
||||
assert content is None
|
||||
assert missing is True
|
||||
|
||||
content, missing = load_previous_monthly_background(output, date(2024, 11, 27))
|
||||
assert content is None
|
||||
assert missing is False
|
||||
@ -1430,7 +1430,7 @@ def test_cli_summarize_prefetches_before_reading(tmp_path, monkeypatch):
|
||||
assert output.read_text(encoding="utf-8") == (
|
||||
"---\nversion: 0.1.0.dev0+test\n"
|
||||
f"model: {DEFAULT_MODEL}\nis_read: false\n"
|
||||
"tags:\n- no_previous_day_log\n- no_previous_weekly\n---\n\n# 合成总结\n")
|
||||
"tags:\n- no_previous_day_log\n- no_previous_weekly\n- no_previous_monthly\n---\n\n# 合成总结\n")
|
||||
|
||||
|
||||
def test_cli_model_failure_happens_before_storage_is_opened(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user