feat(dingtalk): 机器人页脚统一品牌并发布 0.1.4
新增 BRAND 常量,Markdown 页脚固定为「37du 自动化平台 | 时间」,不再重复插件名;同步 api.json 导出清单。
This commit is contained in:
@@ -55,14 +55,20 @@ def test_robot() -> None:
|
||||
_ok("timestamp=" in signed and "sign=" in signed, "有 secret 时追加 timestamp/sign")
|
||||
|
||||
text = robot.render_markdown("标题", "正文", status="error", server_name="署名")
|
||||
_ok("#ff0000" in text and "标题" in text and "正文" in text and "署名" in text,
|
||||
"Markdown 渲染包含状态色/标题/正文/页脚")
|
||||
_ok("#ff0000" in text and "标题" in text and "正文" in text,
|
||||
"Markdown 渲染包含状态色/标题/正文")
|
||||
_ok(robot.BRAND in text and "署名" not in text,
|
||||
"页脚固定平台品牌,不重复调用方标题/署名")
|
||||
|
||||
blocks = [f"block{i}" for i in range(23)]
|
||||
batches = robot.compose_batch_messages(blocks, "【测试】", batch_size=10)
|
||||
_eq(len(batches), 3, "块格式 23 条按 10 分批")
|
||||
_ok("第1/3批" in batches[0] and "本批共10条" in batches[0], "块格式批次头尾")
|
||||
_ok("【测试】" not in batches[0], "批次正文不重复标题前缀")
|
||||
_ok("本批共3条" in batches[2], "最后一批条数正确")
|
||||
_ok("第1/1批" not in robot.compose_batch_messages(["a"], "【测试】")[0]
|
||||
and "【测试】" not in robot.compose_batch_messages(["a"], "【测试】")[0],
|
||||
"单批不加批次标题")
|
||||
_eq(robot.compose_batch_messages([], "x"), [], "空块列表返回空")
|
||||
|
||||
long_text = "\n".join("行" * 50 for _ in range(10))
|
||||
@@ -73,7 +79,7 @@ def test_robot() -> None:
|
||||
|
||||
r = robot.Robot(webhook="https://example.invalid/robot/send", server_name="X",
|
||||
retries=1, log=lambda m: None)
|
||||
_eq(r.server_name, "X", "Robot 页脚署名为显式值")
|
||||
_eq(r.server_name, "X", "Robot server_name 兼容保留")
|
||||
_raises(ValueError, lambda: robot.Robot(webhook=" "), "空 webhook 报错")
|
||||
|
||||
res = robot.push("", log=lambda m: None)
|
||||
|
||||
Reference in New Issue
Block a user