51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
||
"""revise-ai-flavor:修订结论 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" / "quality" / "humanization" / "skills" / "revise-ai-flavor" / "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 revise_ai_flavor import _propose_revision_lesson # noqa: E402
|
||
|
||
|
||
class ReviseLessonOfflineTest(unittest.TestCase):
|
||
def test_conclusion_kinds(self):
|
||
calls: list[dict] = []
|
||
|
||
def fake(**kwargs):
|
||
calls.append(kwargs)
|
||
return {"status": "proposed", "lesson_id": len(calls), "deduped": False}
|
||
|
||
with patch("lesson_registry.propose_lesson_dedup", side_effect=fake):
|
||
_propose_revision_lesson(
|
||
run_id="r1", candidate_sha="ab", conclusion="passed",
|
||
detail={"patches": [1]}, work_ref="w",
|
||
)
|
||
_propose_revision_lesson(
|
||
run_id="r2", candidate_sha="cd", conclusion="no_gain",
|
||
detail={}, work_ref="w",
|
||
)
|
||
_propose_revision_lesson(
|
||
run_id="r3", candidate_sha=None, conclusion="blocked",
|
||
detail={}, work_ref="w",
|
||
)
|
||
self.assertEqual(calls[0]["kind"], "win")
|
||
self.assertEqual(calls[0]["title"], "AI 味修订 patch 通过硬门")
|
||
self.assertEqual(calls[1]["kind"], "lesson")
|
||
self.assertEqual(calls[1]["title"], "AI 味修订未获 pairwise 增益")
|
||
self.assertEqual(calls[2]["title"], "AI 味修订被硬门或回归阻断")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
unittest.main()
|