| |
| """ |
| Test individual components without full app startup |
| """ |
|
|
| import asyncio |
| import sys |
| from pathlib import 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") |
| |
| |
| 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 |
| |
| |
| 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()) |