-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_graph_rag.py
More file actions
85 lines (62 loc) · 2.68 KB
/
Copy pathtest_graph_rag.py
File metadata and controls
85 lines (62 loc) · 2.68 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
Тесты для GraphRAG Query Engine.
"""
from src.core.graph_rag import GraphRAGQueryEngine
class TestGraphRAGQueryEngine:
"""Тесты GraphRAGQueryEngine."""
def test_init(self, tmp_path):
"""Инициализация движка."""
engine = GraphRAGQueryEngine(tmp_path)
assert engine.project_path == tmp_path
assert engine._graph == {}
def test_build_graph_empty(self, tmp_path):
"""Построение графа без symbol_index."""
engine = GraphRAGQueryEngine(tmp_path)
graph = engine.build_graph()
assert "nodes" in graph
assert "stats" in graph
assert graph["stats"]["total_nodes"] == 0
def test_query_impact_no_symbol_index(self, tmp_path):
"""Impact запрос без symbol_index."""
engine = GraphRAGQueryEngine(tmp_path)
result = engine.query_impact("test_symbol")
assert result["symbol"] == "test_symbol"
assert result["direct_impact"] == []
def test_query_feature(self, tmp_path):
"""Feature запрос."""
engine = GraphRAGQueryEngine(tmp_path)
result = engine.query_feature("test_feature")
assert result["feature"] == "test_feature"
assert "files" in result
assert "symbols" in result
def test_query_dependencies(self, tmp_path):
"""Dependencies запрос."""
engine = GraphRAGQueryEngine(tmp_path)
result = engine.query_dependencies("test_file.py")
assert result["file"] == "test_file.py"
assert "depends_on" in result
assert "depended_by" in result
def test_query_tests(self, tmp_path):
"""Tests запрос."""
engine = GraphRAGQueryEngine(tmp_path)
tests = engine.query_tests("test_file.py")
assert isinstance(tests, list)
def test_find_related_tests(self, tmp_path):
"""Поиск связанных тестов."""
engine = GraphRAGQueryEngine(tmp_path)
# Create tests directory
test_dir = tmp_path / "tests"
test_dir.mkdir()
(test_dir / "test_searcher.py").write_text("# test")
tests = engine._find_related_tests(["src/core/searcher.py"])
assert isinstance(tests, list)
def test_query_hotspots_no_memory(self, tmp_path):
"""Hotspots без commit_memory."""
engine = GraphRAGQueryEngine(tmp_path)
result = engine.query_hotspots()
assert result == []
def test_query_similar_bugs_no_memory(self, tmp_path):
"""Similar bugs без commit_memory."""
engine = GraphRAGQueryEngine(tmp_path)
result = engine.query_similar_bugs("test error")
assert result == []