58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""门锚投影:机械验收子串必须对写手可见。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
def _load_production_entry():
|
|
path = (
|
|
Path(__file__).resolve().parents[3]
|
|
/ ".agent" / "skills" / "write-next-chapter" / "scripts" / "produce_next_chapter.py"
|
|
)
|
|
spec = importlib.util.spec_from_file_location("produce_next_chapter", path)
|
|
mod = importlib.util.module_from_spec(spec)
|
|
assert spec.loader is not None
|
|
# 只测纯函数:直接 exec 会拉全依赖;改为复制最小导入路径
|
|
# 实际加载模块(依赖 muse_db 等,本仓 .venv 可用)
|
|
spec.loader.exec_module(mod)
|
|
return mod
|
|
|
|
|
|
class GateConstraintProjectionTests(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.entry = _load_production_entry()
|
|
|
|
def test_ch3_upgrade_anchors_surfaced(self) -> None:
|
|
lines = self.entry.format_mechanical_gate_constraints(self.entry.GATE_ANCHORS[3])
|
|
blob = "\n".join(lines)
|
|
self.assertIn("event-3-upgrade", blob)
|
|
self.assertIn("升级", blob)
|
|
self.assertIn("变强", blob)
|
|
self.assertIn("机械门验收", blob)
|
|
|
|
def test_missing_event_group_still_lists_characters(self) -> None:
|
|
lines = self.entry.format_mechanical_gate_constraints(
|
|
{
|
|
"requiredEvents": [],
|
|
"requiredCharacters": ["林深"],
|
|
"foreshadowingActions": [],
|
|
"chapterEndHook": {
|
|
"requirementId": "hook-x",
|
|
"anchors": ["深渊"],
|
|
"maxDistanceFromEnd": 100,
|
|
},
|
|
}
|
|
)
|
|
blob = "\n".join(lines)
|
|
self.assertIn("林深", blob)
|
|
self.assertIn("深渊", blob)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|