fix: add cross-day dedupe
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from ai_daily_report.publish import load_published_urls
|
||||
from ai_daily_report.runner import run_daily_report
|
||||
|
||||
|
||||
@@ -127,6 +128,36 @@ class RunnerTests(unittest.TestCase):
|
||||
self.assertGreaterEqual(len(fake_client.prompts), 2)
|
||||
self.assertEqual(result["reports"]["stage8"]["status"], "ok")
|
||||
|
||||
def test_run_daily_report_publish_updates_published_url_history(self):
|
||||
class FakeBlogClient:
|
||||
def __init__(self, **kwargs):
|
||||
self.kwargs = kwargs
|
||||
|
||||
def create_post(self, payload):
|
||||
return {"slug": payload["slug"]}
|
||||
|
||||
def publish_post(self, slug):
|
||||
self.slug = slug
|
||||
|
||||
with TemporaryDirectory() as temp_dir:
|
||||
history_path = Path(temp_dir) / "published_urls.json"
|
||||
result = run_daily_report(
|
||||
run_date="2026-06-08",
|
||||
mode="publish",
|
||||
source_mode="mock",
|
||||
llm_mode="mock",
|
||||
out_dir=Path(temp_dir) / "out",
|
||||
base_url="https://blog.example",
|
||||
env={"BLOG_SERVICE_TOKEN": "token"},
|
||||
blog_client_factory=FakeBlogClient,
|
||||
history_path=history_path,
|
||||
)
|
||||
history = load_published_urls(history_path)
|
||||
|
||||
self.assertEqual(result["reports"]["stage8"]["status"], "ok")
|
||||
self.assertIn("https://example.com/gpt5", history.urls)
|
||||
self.assertEqual(history.urls["https://example.com/gpt5"].last_published, "2026-06-08")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user