测试: 覆盖回放执行器外部规划器链路
This commit is contained in:
parent
a54a3a4e39
commit
1243d9b3ff
@ -4,6 +4,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -87,6 +88,34 @@ class ReplayRunTest(unittest.TestCase):
|
|||||||
self.assertNotIn('"prompt":', report)
|
self.assertNotIn('"prompt":', report)
|
||||||
self.assertNotIn('"payload":', report)
|
self.assertNotIn('"payload":', report)
|
||||||
|
|
||||||
|
def test_execute_uses_external_planner_and_validates_each_candidate(self):
|
||||||
|
candidate = {
|
||||||
|
"targetChapter": 489,
|
||||||
|
"chapterGoal": "机制 smoke",
|
||||||
|
"keyEvents": [],
|
||||||
|
"entities": [],
|
||||||
|
"foreshadowing": [],
|
||||||
|
"stateChanges": [],
|
||||||
|
"hook": "下一步",
|
||||||
|
"unknowns": [],
|
||||||
|
"assumptions": [],
|
||||||
|
}
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
fake = pathlib.Path(directory) / "fake-planner.py"
|
||||||
|
fake.write_text(
|
||||||
|
"#!/usr/bin/env python3\n"
|
||||||
|
"import json\n"
|
||||||
|
f"print(json.dumps({{'result': json.dumps({candidate!r}, ensure_ascii=False)}}))\n",
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
os.chmod(fake, 0o755)
|
||||||
|
output_dir = pathlib.Path(directory) / "run"
|
||||||
|
result = run_replay(config(), output_dir, mode="execute", planner_bin=str(fake))
|
||||||
|
self.assertTrue(result["ok"])
|
||||||
|
self.assertEqual(result["status"], "completed")
|
||||||
|
self.assertEqual(set(result["results"]), {"outline_only", "outline_plus_cards", "outline_plus_placebo_cards"})
|
||||||
|
self.assertTrue(list(output_dir.glob("candidate_*.json")))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user