18971a794b
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""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
|