ForcePilot/backend/package/yuxi/channel/sdk/testing/helpers.py
Kris b438af3ba8 feat(channel-sdk): 新增完整的渠道SDK工具链
本提交新增了全渠道SDK核心模块:
1.  异步锁、目标解析、动作调度等基础工具
2.  消息动作注册与统一调度系统
3.  测试套件与契约测试框架
4.  完整的目标解析流水线与工具函数
5.  资源依赖注入与生命周期管理
2026-05-21 10:29:12 +08:00

25 lines
756 B
Python

import asyncio
def assert_msg_id_format(msg_id: str):
assert isinstance(msg_id, str), f"msg_id must be str, got {type(msg_id)}"
assert msg_id.strip(), "msg_id must not be empty or whitespace-only"
def run_async(fn):
return asyncio.run(fn)
def assert_send_call_contains(
sent: list,
index: int,
*,
text_contains: str | None = None,
target_id: str | None = None,
):
assert index < len(sent), f"expected at least {index + 1} send calls, got {len(sent)}"
msg = sent[index]
if text_contains is not None:
assert text_contains in msg.text, f"send[{index}] text does not contain '{text_contains}'"
if target_id is not None:
assert msg.target_id == target_id, f"send[{index}] target_id mismatch"