Spaces:
Sleeping
Sleeping
File size: 1,963 Bytes
551ad28 |
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 |
#!/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()) |