提取 collect/formatters/themes 等 pipeline 模块,新增 wecom 分条、RSS、delta、Agent 工作流测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
|
|
def test_build_movement_context_detects_new_skill(isolated_output, monkeypatch):
|
|
import daily.config as config
|
|
import daily.delta as delta
|
|
|
|
monkeypatch.setattr(config, "OUTPUT_DIR", isolated_output)
|
|
monkeypatch.setattr(delta, "OUTPUT_DIR", isolated_output)
|
|
|
|
prev_path = isolated_output / "2026-07-02.data.json"
|
|
prev_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"data": {
|
|
"date": "2026-07-02",
|
|
"movement_baseline": {
|
|
"skills_trending": [{"id": "a/old", "title": "old"}],
|
|
"skills_hot": [],
|
|
"github_trending": [],
|
|
"github_emerging": [],
|
|
"github_topic": [],
|
|
},
|
|
}
|
|
},
|
|
ensure_ascii=False,
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
trending = [
|
|
{"id": "a/new", "title": "new-skill", "source": "a", "installs": 10, "link": "https://x", "description": ""},
|
|
{"id": "a/old", "title": "old", "source": "a", "installs": 9, "link": "https://y", "description": ""},
|
|
]
|
|
movement = delta.build_movement_context(
|
|
date_str="2026-07-03",
|
|
trending=trending,
|
|
hot=[],
|
|
github_trending=[],
|
|
github_emerging=[],
|
|
github_topic=[],
|
|
)
|
|
|
|
assert movement["baseline_date"] == "2026-07-02"
|
|
assert len(movement["skills_trending_moves"]) == 1
|
|
assert movement["skills_trending_moves"][0]["id"] == "a/new"
|
|
|
|
|
|
def test_find_previous_data_skips_missing_days(isolated_output, monkeypatch):
|
|
import daily.config as config
|
|
import daily.delta as delta
|
|
|
|
monkeypatch.setattr(config, "OUTPUT_DIR", isolated_output)
|
|
monkeypatch.setattr(delta, "OUTPUT_DIR", isolated_output)
|
|
|
|
(isolated_output / "2026-07-01.data.json").write_text(
|
|
json.dumps({"data": {"date": "2026-07-01", "skills_trending": []}}),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
found = delta.find_previous_data("2026-07-03")
|
|
assert found is not None
|
|
assert found[0] == "2026-07-01"
|