feat: 新增企微 Delta 榜单区块渲染与替换逻辑

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-09 11:35:49 +08:00
parent 2f1fac9308
commit e3b5623860
2 changed files with 265 additions and 25 deletions

View File

@@ -100,3 +100,91 @@ class SkillMovePartitionTests(unittest.TestCase):
with patch("daily.delta.wecom_mode", return_value="delta"):
with patch("daily.delta.delta_baseline_fallback", return_value="full"):
self.assertEqual(effective_wecom_mode(date_str="2026-07-10"), "full")
class DeltaFormatTests(unittest.TestCase):
def test_skills_delta_omits_empty_board(self):
from daily.format_wecom import build_skills_delta_sections
moves = [
{
"id": "x/y/z",
"rank": 3,
"title": "z",
"source": "x/y",
"installs": 10,
"installs_fmt": "10",
"link": "https://skills.sh/x/y/z",
"description": "d",
"badge": "Trending #3",
}
]
text = build_skills_delta_sections(moves, [])
self.assertIn("Skills Trending 变化", text)
self.assertIn("[新入 #3]", text)
self.assertNotIn("Skills Hot 变化", text)
def test_github_delta_omits_stable_board(self):
from daily.format_wecom import build_github_delta_sections
movement = {
"github_trending_moves": [
{"repo": "a/b", "url": "https://github.com/a/b", "rank": 1, "language": "Go"}
],
"github_emerging_moves": [],
"github_topic_moves": [],
}
text = build_github_delta_sections(movement, topic_name="llm")
self.assertIn("GitHub Trending 变化", text)
self.assertNotIn("新兴", text)
class PushGateTests(unittest.TestCase):
def test_push_when_board_has_moves(self):
from daily.push_gate import evaluate_push_gate
gate = evaluate_push_gate(
movement={"skills_trending_moves": [{"id": "a/b/c"}], "skills_hot_moves": [], "github_trending_moves": [], "github_emerging_moves": [], "github_topic_moves": []},
ai_news_items=[],
cn_ai_news_items=[],
featured_pick=None,
)
self.assertTrue(gate.should_push)
self.assertIn("board_moves", gate.reasons)
def test_silent_when_all_empty(self):
from daily.push_gate import evaluate_push_gate
gate = evaluate_push_gate(
movement={
"skills_trending_moves": [],
"skills_hot_moves": [],
"github_trending_moves": [],
"github_emerging_moves": [],
"github_topic_moves": [],
},
ai_news_items=[],
cn_ai_news_items=[],
featured_pick=None,
)
self.assertFalse(gate.should_push)
self.assertTrue(gate.silent)
def test_force_push_overrides_silent(self):
from daily.push_gate import evaluate_push_gate
with patch("daily.push_gate.force_push", return_value=True):
gate = evaluate_push_gate(
movement={
"skills_trending_moves": [],
"skills_hot_moves": [],
"github_trending_moves": [],
"github_emerging_moves": [],
"github_topic_moves": [],
},
ai_news_items=[],
cn_ai_news_items=[],
featured_pick=None,
)
self.assertTrue(gate.should_push)
self.assertIn("force_push", gate.reasons)