42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""审核知识卡:审核写回 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" / "review" / "审核知识卡" / "scripts"
|
|
EVIDENCE = ROOT / "muse" / "authority" / "evidence" / "skills" / "记录运行证据" / "scripts"
|
|
for path in (SCRIPT, EVIDENCE):
|
|
if str(path) not in sys.path:
|
|
sys.path.insert(0, str(path))
|
|
|
|
from review_cards import _propose_review_lesson # noqa: E402
|
|
|
|
|
|
class ReviewLessonOfflineTest(unittest.TestCase):
|
|
def test_registers_win_with_batch_key(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_review_lesson(
|
|
work_id=3, batch="cal-1", stats={"pass": 2, "revise": 1}, shard="a",
|
|
)
|
|
self.assertEqual(out["lesson_id"], 4)
|
|
self.assertEqual(calls[0]["kind"], "win")
|
|
self.assertEqual(calls[0]["title"], "知识卡三角色审核已写回")
|
|
self.assertEqual(calls[0]["run_id"], "review-3-cal-1-a")
|
|
self.assertEqual(calls[0]["detail"]["pass"], 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|