muse-agent-example/tests/skills/完善故事基础设定/test_assert_selection_handoff.py
zizi 7f9114eca5 W13 旧用例承接补充:作者层路由与中文方法 Skill 的已跟踪文件改动
作者场景路由与指令、完善故事基础设定/合并故事方案/制定作品规划的技能中文化重构及其脚本、对应旧测试修改、SOT 导读、技能目录与实现回顾。此为 W13 阶段对已跟踪文件的改动,随批次按阶段整理补提交。
2026-09-10 19:39:47 +08:00

46 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""完善故事基础设定 选定交接闸离线测试。"""
import sys
from pathlib import Path
import click
PROJECT_ROOT = Path(__file__).resolve().parents[3]
SCRIPTS = PROJECT_ROOT / "muse" / "lifecycle" / "flow" / "skills" / "book" / "完善故事基础设定" / "scripts"
sys.path.insert(0, str(SCRIPTS))
from assert_selection_handoff import HandoffError, assert_selection_handoff # noqa: E402
def expect_fail(payload) -> None:
try:
assert_selection_handoff(payload)
except HandoffError:
return
raise AssertionError("应失败关闭")
def main() -> None:
ok = assert_selection_handoff({
"selectedCandidate": ".agents.local/草稿/作品/作品探索.md",
"confirmedByUser": True,
"confirmedAt": "2026-08-20T12:00:00+08:00",
})
assert ok["selectedCandidate"].endswith("作品探索.md")
expect_fail({})
expect_fail({"selectedCandidate": "x", "confirmedByUser": False, "confirmedAt": "t"})
for unconfirmed in ("false", "true", "user", 1, ["true"]):
expect_fail({"selectedCandidate": "x", "confirmedByUser": unconfirmed, "confirmedAt": "t"})
expect_fail({"selectedCandidate": "", "confirmedByUser": True, "confirmedAt": "t"})
expect_fail({"selectedCandidate": ["x"], "confirmedByUser": True, "confirmedAt": "t"})
expect_fail({"selectedCandidate": "x", "confirmedByUser": True, "confirmedAt": " "})
try:
raise HandoffError("x")
except click.ClickException:
pass
print("PASS:selection handoff 门全部通过")
if __name__ == "__main__":
main()