Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Test script for the MCP server | |
| """ | |
| import asyncio | |
| import sys | |
| import os | |
| import time | |
| import signal | |
| # Add the web directory to the path | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) | |
| def test_mcp_server_import(): | |
| """Test that we can import the MCP server module.""" | |
| try: | |
| from mcp_server import RTSGameMCP | |
| print("โ Successfully imported RTSGameMCP") | |
| return True | |
| except Exception as e: | |
| print(f"โ Failed to import RTSGameMCP: {e}") | |
| return False | |
| def test_mcp_server_creation(): | |
| """Test that we can create an MCP server instance.""" | |
| try: | |
| from mcp_server import RTSGameMCP | |
| server = RTSGameMCP() | |
| print("โ Successfully created RTSGameMCP instance") | |
| return True | |
| except Exception as e: | |
| print(f"โ Failed to create RTSGameMCP instance: {e}") | |
| return False | |
| async def test_mcp_server_startup(): | |
| """Test that we can start the MCP server.""" | |
| try: | |
| from mcp_server import RTSGameMCP | |
| server = RTSGameMCP() | |
| # This would normally start the server, but we'll just test initialization | |
| print("โ MCP server initialization successful") | |
| return True | |
| except Exception as e: | |
| print(f"โ Failed to initialize MCP server: {e}") | |
| return False | |
| def main(): | |
| """Run all tests.""" | |
| print("Testing MCP server...") | |
| tests = [ | |
| test_mcp_server_import, | |
| test_mcp_server_creation, | |
| test_mcp_server_startup, | |
| ] | |
| results = [] | |
| for test in tests: | |
| if asyncio.iscoroutinefunction(test): | |
| results.append(asyncio.run(test())) | |
| else: | |
| results.append(test()) | |
| if all(results): | |
| print("\nโ All MCP server tests passed!") | |
| return 0 | |
| else: | |
| print("\nโ Some MCP server tests failed!") | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) |