Files
daily-robots/tests/test_wecom_split.py
yumao ce04d5a342
Some checks failed
test / pytest (push) Failing after 3s
daily / report (push) Failing after 1s
refactor: Phase 3 拆分 generate 流水线并补全测试
提取 collect/formatters/themes 等 pipeline 模块,新增 wecom 分条、RSS、delta、Agent 工作流测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-03 14:59:12 +08:00

35 lines
1.1 KiB
Python

from __future__ import annotations
from daily.wecom_split import split_wecom_messages
def test_split_wecom_messages_keeps_short_text():
text = "📰 **早报 · 2026-07-03**\n\n短内容"
parts = split_wecom_messages(text, limit=4096)
assert parts == [text]
def test_split_wecom_messages_adds_part_footer():
section = "📰 **早报**\n\n" + ("正文行\n" * 200)
parts = split_wecom_messages(section, limit=600)
assert len(parts) > 1
assert all(len(part.encode("utf-8")) <= 600 for part in parts)
assert parts[0].endswith("1/" + str(len(parts)))
def test_split_sections_on_emoji_headers():
from daily.wecom_split import _split_sections
text = "\n\n".join(
[
"📰 **早报 · 2026-07-03**",
"💡 **今日速览**\n- item one\n- item two",
"🌍 **国际 AI 时讯**\n1. [Headline](https://example.com)",
]
)
sections = _split_sections(text)
assert len(sections) == 3
assert sections[0].startswith("📰")
assert sections[1].startswith("💡")
assert sections[2].startswith("🌍")