40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
||
"""extract-work-knowledge:升格窗批 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" / "extract-work-knowledge" / "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 upgrade import _propose_upgrade_lesson # noqa: E402
|
||
|
||
|
||
class UpgradeLessonOfflineTest(unittest.TestCase):
|
||
def test_registers_win(self):
|
||
calls: list[dict] = []
|
||
|
||
def fake(**kwargs):
|
||
calls.append(kwargs)
|
||
return {"status": "proposed", "lesson_id": 2, "deduped": False}
|
||
|
||
with patch("lesson_registry.propose_lesson_dedup", side_effect=fake):
|
||
out = _propose_upgrade_lesson(work_id=5, title="深空", done_n=4, calls_n=12)
|
||
self.assertEqual(out["lesson_id"], 2)
|
||
self.assertEqual(calls[0]["kind"], "win")
|
||
self.assertEqual(calls[0]["title"], "作品面知识升格窗批完成")
|
||
self.assertEqual(calls[0]["detail"]["windows_done"], 4)
|
||
self.assertEqual(calls[0]["run_id"], "upgrade-5-done4")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
unittest.main()
|