feat: 新增企微已推送新闻 link 去重缓存
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from daily.config import (
|
||||
@@ -14,6 +16,7 @@ from daily.config import (
|
||||
skip_push_when_silent,
|
||||
wecom_mode,
|
||||
)
|
||||
from daily.news.pushed_links import filter_unpushed_items, record_pushed_links
|
||||
|
||||
|
||||
class ConfigHelpersTests(unittest.TestCase):
|
||||
@@ -40,3 +43,19 @@ class ConfigHelpersTests(unittest.TestCase):
|
||||
def test_delta_baseline_fallback_default(self):
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
self.assertEqual(delta_baseline_fallback(), "full")
|
||||
|
||||
|
||||
class NewsPushedLinksTests(unittest.TestCase):
|
||||
def test_filter_and_record_roundtrip(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
cache = Path(tmp) / "pushed-news-links.json"
|
||||
items = [
|
||||
{"title": "A", "link": "https://example.com/a?utm_source=x"},
|
||||
{"title": "B", "link": "https://example.com/b"},
|
||||
]
|
||||
with patch("daily.news.pushed_links._cache_path", return_value=cache):
|
||||
with patch("daily.news.pushed_links.news_dedup_days", return_value=7):
|
||||
record_pushed_links("2026-07-08", ["https://example.com/a"])
|
||||
out = filter_unpushed_items(items, date_str="2026-07-09")
|
||||
self.assertEqual(len(out), 1)
|
||||
self.assertEqual(out[0]["link"], "https://example.com/b")
|
||||
|
||||
Reference in New Issue
Block a user