Files
CraftKit/migration/tests/test_dev_design_batch.py
T

59 lines
2.2 KiB
Python

"""开发分析与设计批次的职责边界测试。"""
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[2]
SKILLS = ROOT / "plugins" / "dev" / "skills"
def read_skill(name: str) -> str:
"""合并读取 Skill 入口及引用文件。"""
folder = SKILLS / name
files = [folder / "SKILL.md", *sorted((folder / "references").glob("*.md"))]
return "\n".join(path.read_text(encoding="utf-8") for path in files)
class DevDesignBatchTest(unittest.TestCase):
"""验证四个 Skill 的通用化设计和相互边界。"""
def test_plan_is_evidence_based_and_does_not_implement(self) -> None:
content = read_skill("plan-change")
self.assertIn("不执行设计或编码", content)
self.assertIn("验收标准", content)
self.assertIn("运行行为标为待验证", content)
self.assertNotIn("docs/{moduleCode}", content)
def test_backend_design_uses_project_version(self) -> None:
content = read_skill("design-backend")
self.assertIn("精确版本", content)
self.assertIn("guidance", content)
self.assertIn("事务边界", content)
self.assertIn("不生成业务代码", content)
def test_frontend_design_composes_existing_helpers(self) -> None:
content = read_skill("design-frontend")
for helper in ("component", "style", "form", "prepare-api"):
self.assertIn(helper, content)
self.assertIn("不编造组件", content)
self.assertIn("不跨版本混用", content)
def test_prepare_api_does_not_assume_contract(self) -> None:
content = read_skill("prepare-api")
self.assertIn("不预设请求客户端", content)
self.assertIn("未匹配字段", content)
self.assertIn("不发起真实请求", content)
self.assertIn("不能反向覆盖", content)
def test_descriptions_are_distinct(self) -> None:
descriptions = []
for name in ("plan-change", "design-backend", "design-frontend", "prepare-api"):
text = (SKILLS / name / "SKILL.md").read_text(encoding="utf-8")
descriptions.append(text.split("---", 2)[1])
self.assertEqual(4, len(set(descriptions)))
if __name__ == "__main__":
unittest.main()