feat(tree/repair): Q&A 反向补全 — 从 TRM4 supplement 迁移

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-07 02:37:50 -04:00
parent edaa0d8290
commit 18971a794b
2 changed files with 560 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
"""Q&A 反向补全单元测试。"""
from __future__ import annotations
from app.tree.repair.supplement import SupplementStats, deduplicate_field
class TestDeduplicateField:
def test_removes_duplicates(self):
result = deduplicate_field(["Hello", "hello", "World", "HELLO"])
assert result == ["Hello", "World"]
def test_preserves_order(self):
result = deduplicate_field(["B", "A", "b", "C"])
assert result == ["B", "A", "C"]
def test_strips_whitespace(self):
result = deduplicate_field([" hello ", "hello"])
assert len(result) == 1
def test_empty_list(self):
assert deduplicate_field([]) == []
def test_skips_empty_strings(self):
result = deduplicate_field(["", "hello", "", "world"])
assert result == ["hello", "world"]
class TestSupplementStats:
def test_defaults(self):
stats = SupplementStats()
assert stats.questions_analyzed == 0
assert stats.facts_injected == 0
assert stats.facts_skipped == 0