muse-agent-example/tests/skills/assemble-context/test_freeze_lesson_offline.py

42 lines
1.4 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
"""assemble-context:冻结 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" / "lifecycle" / "context" / "skills" / "assemble-context" / "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 persist_context_freeze import _propose_freeze_lesson # noqa: E402
class FreezeLessonOfflineTest(unittest.TestCase):
def test_registers_win(self):
calls: list[dict] = []
def fake(**kwargs):
calls.append(kwargs)
return {"status": "proposed", "lesson_id": 4, "deduped": False}
with patch("lesson_registry.propose_lesson_dedup", side_effect=fake):
out = _propose_freeze_lesson(
run_id="ctx-1", work_id=9, target_chapter=3, as_of=2,
manifest_sha="m" * 64, context_sha="c" * 64, section_count=5,
)
self.assertEqual(out["lesson_id"], 4)
self.assertEqual(calls[0]["kind"], "win")
self.assertEqual(calls[0]["title"], "写作上下文已冻结")
self.assertEqual(calls[0]["creator"], "read-context")
if __name__ == "__main__":
unittest.main()