-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_cli_direct.py
More file actions
73 lines (57 loc) · 1.83 KB
/
test_cli_direct.py
File metadata and controls
73 lines (57 loc) · 1.83 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
73
#!/usr/bin/env python3
"""
Direct test of the MCP Server CLI
"""
import sys
import os
# Add the current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def test_cli_help():
"""Test CLI help command"""
print("Testing CLI help command...")
try:
from mcp_server.__main__ import cli
# Simulate command line arguments
sys.argv = ['mcp_server', '--help']
# This should print help and exit
cli()
except SystemExit as e:
if e.code == 0:
print("✅ CLI help command works")
return True
else:
print(f"❌ CLI help command failed with exit code: {e.code}")
return False
except Exception as e:
print(f"❌ CLI help command failed with error: {e}")
return False
def test_cli_version():
"""Test CLI version command"""
print("Testing CLI version command...")
try:
from mcp_server.__main__ import cli
# Simulate command line arguments
sys.argv = ['mcp_server', '--version']
# This should print version and exit
cli()
except SystemExit as e:
if e.code == 0:
print("✅ CLI version command works")
return True
else:
print(f"❌ CLI version command failed with exit code: {e.code}")
return False
except Exception as e:
print(f"❌ CLI version command failed with error: {e}")
return False
if __name__ == "__main__":
print("🧪 MCP Server CLI Direct Test\n")
success = True
success &= test_cli_help()
success &= test_cli_version()
if success:
print("\n🎉 All CLI tests passed!")
exit(0)
else:
print("\n❌ Some CLI tests failed!")
exit(1)