-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest_server.py
More file actions
56 lines (47 loc) · 1.81 KB
/
test_server.py
File metadata and controls
56 lines (47 loc) · 1.81 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
#!/usr/bin/env python3
"""
Test script for the MCP man pages server functionality.
This script tests the core functionality of the server.
"""
import sys
import asyncio
from pathlib import Path
# Add server directory to path
server_dir = Path(__file__).parent / "server"
sys.path.insert(0, str(server_dir))
from main import man_service
async def test_server_functionality():
"""Test the core server functionality."""
print("🧪 Testing server functionality...")
# Test 1: Search functionality
print("🔍 Testing search functionality...")
try:
result = await man_service.search_man_pages('ls')
assert len(result) > 0, 'Search should return results'
print(f"✅ Search test passed - found {len(result)} results")
except Exception as e:
print(f"❌ Search test failed: {e}")
return False
# Test 2: Page retrieval
print("📖 Testing page retrieval...")
try:
content = await man_service.get_man_page('ls', '1')
assert content and len(content) > 100, 'Man page content should not be empty'
print(f"✅ Page retrieval test passed - got {len(content)} characters")
except Exception as e:
print(f"❌ Page retrieval test failed: {e}")
return False
# Test 3: Section listing
print("📚 Testing section listing...")
try:
sections = await man_service.list_sections()
assert len(sections) > 0, 'Should return available sections'
print(f"✅ Section listing test passed - found {len(sections)} sections")
except Exception as e:
print(f"❌ Section listing test failed: {e}")
return False
print("✅ All server functionality tests passed!")
return True
if __name__ == "__main__":
success = asyncio.run(test_server_functionality())
sys.exit(0 if success else 1)