- 新增常驻调度器 daily/scheduler.py + run-scheduler.ps1(定时生成/推送) - 新增 daily/bridge_manager.py:Windows 兼容的 Cursor SDK 桥接 - 新增 skills/daily-featured-pick 首推 Skill 与叙事轴/去重逻辑 - 新闻抓取窗口、GitHub 搜索、企微 delta 模式等多项改进 - 补充设计文档与 superpowers 计划/规范 - 新增对应测试(scheduler、featured_pick、github_search、news_fetch_window 等) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
# tests/test_board_select.py
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from daily.board_select import board_select
|
|
|
|
|
|
def _gh(repo: str) -> dict:
|
|
return {"repo": repo, "description": repo}
|
|
|
|
|
|
class BoardSelectTests(unittest.TestCase):
|
|
def test_filters_recent_and_keeps_order(self):
|
|
pool = [_gh(f"o/r{i}") for i in range(20)]
|
|
recent = {"o/r0", "o/r1", "o/r2"}
|
|
out = board_select(
|
|
board="github_trending",
|
|
items=pool,
|
|
recent_keys=recent,
|
|
limit=5,
|
|
pool_size=20,
|
|
kind="github",
|
|
)
|
|
keys = [x["repo"] for x in out]
|
|
self.assertEqual(keys, ["o/r3", "o/r4", "o/r5", "o/r6", "o/r7"])
|
|
|
|
def test_deep_pool_fills_after_filter(self):
|
|
pool = [_gh(f"o/r{i}") for i in range(8)]
|
|
recent = {f"o/r{i}" for i in range(6)} # 前 6 全封
|
|
out = board_select(
|
|
board="github_emerging",
|
|
items=pool,
|
|
recent_keys=recent,
|
|
limit=5,
|
|
pool_size=8,
|
|
kind="github",
|
|
)
|
|
self.assertEqual([x["repo"] for x in out], ["o/r6", "o/r7"]) # 短榜
|
|
|
|
def test_skill_uses_skill_id(self):
|
|
items = [
|
|
{"id": "a/b/s1", "source": "a/b", "title": "s1", "installs": 10},
|
|
{"id": "c/d/s2", "source": "c/d", "title": "s2", "installs": 9},
|
|
]
|
|
out = board_select(
|
|
board="skills_trending",
|
|
items=items,
|
|
recent_keys={"a/b/s1"},
|
|
limit=10,
|
|
pool_size=50,
|
|
kind="skill",
|
|
)
|
|
self.assertEqual([x["id"] for x in out], ["c/d/s2"])
|
|
|
|
def test_skill_filters_recent_by_source(self):
|
|
items = [
|
|
{"id": "a/b/s-new", "source": "a/b", "title": "s-new", "installs": 10},
|
|
{"id": "c/d/s2", "source": "c/d", "title": "s2", "installs": 9},
|
|
]
|
|
out = board_select(
|
|
board="skills_hot",
|
|
items=items,
|
|
recent_keys={"a/b"}, # source-level history
|
|
limit=10,
|
|
pool_size=50,
|
|
kind="skill",
|
|
)
|
|
self.assertEqual([x["id"] for x in out], ["c/d/s2"])
|
|
|
|
def test_skill_filters_recent_skill_id_as_same_source(self):
|
|
from daily.format_wecom import expand_skill_recent_keys
|
|
|
|
items = [
|
|
{"id": "open.feishu.cn/lark-drive", "source": "open.feishu.cn", "title": "lark-drive", "installs": 10},
|
|
{"id": "fresh/src/s", "source": "fresh/src", "title": "s", "installs": 9},
|
|
]
|
|
recent = expand_skill_recent_keys({"open.feishu.cn/lark-doc"})
|
|
out = board_select(
|
|
board="skills_trending",
|
|
items=items,
|
|
recent_keys=recent,
|
|
limit=10,
|
|
pool_size=50,
|
|
kind="skill",
|
|
)
|
|
self.assertEqual([x["id"] for x in out], ["fresh/src/s"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|