File size: 2,939 Bytes
2adda07 | 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 | #!/usr/bin/env python3
"""
Test individual components without full app startup
"""
import asyncio
import sys
from pathlib import Path
# Add current directory to path
sys.path.insert(0, str(Path(__file__).parent))
async def test_imports():
"""Test that all modules can be imported"""
print("π¦ Testing imports...")
try:
import anthropic
print("β
anthropic imported")
import gradio
print("β
gradio imported")
from shared.config import config
print("β
shared.config imported")
# Test main app import (but don't run it)
import als_agent_app
print("β
als_agent_app imported")
return True
except Exception as e:
print(f"β Import failed: {e}")
return False
async def test_config():
"""Test configuration loading"""
print("\nβοΈ Testing configuration...")
try:
from shared.config import config
print(f"Anthropic model: {config.anthropic_model}")
print(f"Gradio port: {config.gradio_port}")
print(f"API key set: {'Yes' if config.anthropic_api_key and config.anthropic_api_key != 'your_anthropic_api_key_here' else 'No'}")
return True
except Exception as e:
print(f"β Config test failed: {e}")
return False
async def test_mcp_server_files():
"""Test that MCP server files exist and can be imported"""
print("\nπ₯οΈ Testing MCP server files...")
try:
servers_dir = Path("servers")
expected_servers = [
"pubmed_server.py",
"biorxiv_server.py",
"clinicaltrials_server.py",
"fetch_server.py"
]
for server_file in expected_servers:
server_path = servers_dir / server_file
if server_path.exists():
print(f"β
{server_file} exists")
else:
print(f"β {server_file} missing")
return False
# Test basic import (without running servers)
import servers.pubmed_server
print("β
pubmed_server can be imported")
return True
except Exception as e:
print(f"β MCP server test failed: {e}")
return False
async def main():
"""Run component tests"""
print("π§ͺ Testing Individual Components\n")
tests = [
test_imports,
test_config,
test_mcp_server_files
]
results = []
for test in tests:
result = await test()
results.append(result)
print(f"\nπ Component Test Results:")
print(f"Passed: {sum(results)}/{len(results)}")
if all(results):
print("π All component tests passed!")
else:
print("β οΈ Some component tests failed.")
if __name__ == "__main__":
asyncio.run(main()) |