提取 collect/formatters/themes 等 pipeline 模块,新增 wecom 分条、RSS、delta、Agent 工作流测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
1.1 KiB
Python
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("🌍")
|