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())