muse-agent-example/tests/skills/deconstruct-book/test_deconstruct_lesson_offline.py

39 lines
1.3 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
"""deconstruct-book:窗大纲 lesson 离线钉死。"""
from __future__ import annotations
import pathlib
import sys
import unittest
from unittest.mock import patch
ROOT = pathlib.Path(__file__).resolve().parents[3]
SCRIPT = ROOT / "muse" / "content" / "entity" / "skills" / "ingest" / "deconstruct-book" / "scripts"
EVIDENCE = ROOT / "muse" / "authority" / "evidence" / "skills" / "record-run-evidence" / "scripts"
for path in (SCRIPT, EVIDENCE):
if str(path) not in sys.path:
sys.path.insert(0, str(path))
from parse_outline import _propose_deconstruct_lesson # noqa: E402
class DeconstructLessonOfflineTest(unittest.TestCase):
def test_registers_win(self):
calls: list[dict] = []
def fake(**kwargs):
calls.append(kwargs)
return {"status": "proposed", "lesson_id": 1, "deduped": False}
with patch("lesson_registry.propose_lesson_dedup", side_effect=fake):
out = _propose_deconstruct_lesson(work_id=7, title="深空", window_count=3)
self.assertEqual(out["lesson_id"], 1)
self.assertEqual(calls[0]["kind"], "win")
self.assertEqual(calls[0]["title"], "拆书窗大纲聚合完成")
self.assertEqual(calls[0]["run_id"], "deconstruct-window-7-n3")
if __name__ == "__main__":
unittest.main()