forked from odsc2015/agentic-hackathon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
130 lines (96 loc) · 3.42 KB
/
test_setup.py
File metadata and controls
130 lines (96 loc) · 3.42 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
129
130
#!/usr/bin/env python3
"""
Quick test script to verify the setup is working
"""
import sys
import os
def test_imports():
"""Test all critical imports"""
print("🧪 Testing imports...")
try:
from src.config import Config
print("✅ Config")
from src.utils import setup_logging, sanitize_input
print("✅ Utils")
from src.models import MedicalQuery, MedicalResponse
print("✅ Models")
from src.memory import ConversationMemory, CacheManager
print("✅ Memory")
from src.planner import QueryPlanner
print("✅ Planner")
from src.executor import ToolExecutor
print("✅ Executor")
from src.agent import HealthcareNavigatorAgent
print("✅ Agent")
import streamlit
print("✅ Streamlit")
return True
except ImportError as e:
print(f"❌ Import error: {e}")
return False
def test_basic_functionality():
"""Test basic functionality without API calls"""
print("\n🔧 Testing basic functionality...")
try:
from src.agent import HealthcareNavigatorAgent
from src.models import MedicalQuery
# Test agent initialization
agent = HealthcareNavigatorAgent("test_session")
print("✅ Agent initialization")
# Test query creation
query = MedicalQuery(query_text="What is diabetes?")
print("✅ Query creation")
# Test input sanitization
from src.utils import sanitize_input
sanitized = sanitize_input("Test <script>alert('xss')</script> input")
print("✅ Input sanitization")
return True
except Exception as e:
print(f"❌ Functionality error: {e}")
return False
def test_environment():
"""Test environment configuration"""
print("\n🌍 Testing environment...")
try:
from src.config import Config
# Check if .env file exists
if os.path.exists('.env'):
print("✅ .env file exists")
else:
print("⚠️ .env file not found (using defaults)")
# Test config loading
config_test = hasattr(Config, 'LOG_LEVEL')
if config_test:
print("✅ Config loading")
else:
print("❌ Config loading failed")
return True
except Exception as e:
print(f"❌ Environment error: {e}")
return False
def main():
"""Run all tests"""
print("🏥 Healthcare Navigator - Setup Test")
print("=" * 40)
tests_passed = 0
total_tests = 3
if test_imports():
tests_passed += 1
if test_basic_functionality():
tests_passed += 1
if test_environment():
tests_passed += 1
print("\n" + "=" * 40)
print(f"📊 Test Results: {tests_passed}/{total_tests} passed")
if tests_passed == total_tests:
print("🎉 All tests passed! Your setup is ready.")
print("\n🚀 Next steps:")
print("1. Add your API keys to .env file")
print("2. Run: streamlit run web_app.py")
print("3. Or try: python cli.py --query 'What is diabetes?'")
else:
print("❌ Some tests failed. Check the errors above.")
return 1
return 0
if __name__ == "__main__":
sys.exit(main())