forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_synonym_expansion.py
More file actions
45 lines (35 loc) 路 1.4 KB
/
Copy pathtest_synonym_expansion.py
File metadata and controls
45 lines (35 loc) 路 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"""Tests for domain synonym query expansion."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from misakanet.search.engine import _SYNONYM_MAP, _expand_query
class TestSynonymExpansion:
def test_expand_mcp(self):
result = _expand_query("mcp tool not showing")
assert "setup" in result
assert "tools/list" in result
def test_expand_gbk(self):
result = _expand_query("gbk error")
assert "unicode" in result
assert "encoding" in result
def test_expand_dco(self):
result = _expand_query("dco fail")
assert "signoff" in result
def test_expand_pip(self):
result = _expand_query("pip timeout")
assert "ssl" in result
assert "proxy" in result
def test_unmapped_query_unchanged(self):
original = "database locked"
result = _expand_query(original)
assert result == original
def test_no_duplicate_synonyms(self):
result = _expand_query("dco")
tokens = result.split()
assert len(tokens) == len(set(tokens))
def test_synonym_map_is_dict(self):
assert isinstance(_SYNONYM_MAP, dict)
def test_common_terms_have_synonyms(self):
for term in ["mcp", "gbk", "dco", "pip", "git", "auth", "cron", "wsl"]:
assert term in _SYNONYM_MAP, f"Missing synonym entry for {term}"