-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_basic.py
More file actions
72 lines (60 loc) · 2.13 KB
/
Copy pathtest_basic.py
File metadata and controls
72 lines (60 loc) · 2.13 KB
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
"""
Simple functionality test for AgentMCP
Basic test to ensure core features work
"""
import asyncio
import sys
import os
# Add current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
async def test_basic_functionality():
"""Test basic functionality works"""
print("Testing AgentMCP basic functionality...")
# Test 1: Import core modules
try:
from agent_mcp.mcp_decorator import mcp_agent
from agent_mcp.mcp_transport import HTTPTransport
print("✓ Core imports successful")
except ImportError as e:
print(f"✗ Core import failed: {e}")
return False
# Test 2: Create basic agent
try:
@mcp_agent(mcp_id="test_basic")
class BasicAgent:
async def process_message(self, message: str) -> str:
return f"Processed: {message}"
agent = BasicAgent()
print("✓ Basic agent creation successful")
except Exception as e:
print(f"✗ Basic agent creation failed: {e}")
return False
# Test 3: Create transport
try:
transport = HTTPTransport(port=8090)
print("✓ Transport creation successful")
except Exception as e:
print(f"✗ Transport creation failed: {e}")
return False
# Test 4: Connect agent to transport
try:
agent.transport = transport
print("✓ Agent transport assignment successful")
except Exception as e:
print(f"✗ Agent transport assignment failed: {e}")
return False
# Test 5: Register agent with transport
try:
# Mock server URL for testing
transport.remote_url = "http://localhost:8090"
agent.is_remote = True
transport.agent_name = "test_basic"
transport.token = "test_token"
print("✓ Agent transport configuration successful")
except Exception as e:
print(f"✗ Agent transport configuration failed: {e}")
return False
print("✓ All basic functionality tests passed!")
return True
if __name__ == "__main__":
asyncio.run(test_basic_functionality())