-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_tests.py
More file actions
128 lines (99 loc) · 3.53 KB
/
Copy pathdebug_tests.py
File metadata and controls
128 lines (99 loc) · 3.53 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python3
"""
Debug script to identify test failures
"""
import sys
import os
# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_imports():
"""Test if all required modules can be imported."""
print("Testing imports...")
try:
import pytest
print("✅ pytest imported successfully")
except ImportError as e:
print(f"❌ pytest import failed: {e}")
return False
try:
from knowledge_graph.data_processor import preprocess_data
print("✅ data_processor imported successfully")
except ImportError as e:
print(f"❌ data_processor import failed: {e}")
return False
try:
from knowledge_graph.graph_builder import build_graph
print("✅ graph_builder imported successfully")
except ImportError as e:
print(f"❌ graph_builder import failed: {e}")
return False
try:
from rag.biomedical_rag import BiomedicalRAG
print("✅ BiomedicalRAG imported successfully")
except ImportError as e:
print(f"❌ BiomedicalRAG import failed: {e}")
return False
try:
from rag.query_processor import QueryProcessor
print("✅ QueryProcessor imported successfully")
except ImportError as e:
print(f"❌ QueryProcessor import failed: {e}")
return False
try:
from rag.response_generator import ResponseGenerator
print("✅ ResponseGenerator imported successfully")
except ImportError as e:
print(f"❌ ResponseGenerator import failed: {e}")
return False
return True
def test_fixtures():
"""Test if fixtures can be created."""
print("\nTesting fixtures...")
try:
from tests.conftest import sample_data, sample_graph
print("✅ sample_data fixture created successfully")
print(f" - Diseases: {sample_data['diseases']}")
print(f" - Symptoms: {sample_data['symptoms']}")
print(f" - Relationships: {len(sample_data['relationships'])}")
print("✅ sample_graph fixture created successfully")
print(f" - Nodes: {len(sample_graph.nodes)}")
print(f" - Edges: {len(sample_graph.edges)}")
return True
except Exception as e:
print(f"❌ Fixture creation failed: {e}")
import traceback
traceback.print_exc()
return False
def test_basic_functionality():
"""Test basic functionality."""
print("\nTesting basic functionality...")
try:
from tests.conftest import sample_graph
from rag.biomedical_rag import BiomedicalRAG
rag = BiomedicalRAG(sample_graph)
print("✅ BiomedicalRAG created successfully")
# Test a simple query
response = rag.answer_query("What are diabetes symptoms?")
print(f"✅ Query processed successfully: {response[:100]}...")
return True
except Exception as e:
print(f"❌ Basic functionality test failed: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == "__main__":
print("🔍 Debugging Biomedical Assistant Tests")
print("=" * 50)
success = True
if not test_imports():
success = False
if not test_fixtures():
success = False
if not test_basic_functionality():
success = False
print("\n" + "=" * 50)
if success:
print("🎉 All tests passed!")
else:
print("❌ Some tests failed. Check the output above.")
sys.exit(0 if success else 1)