FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/tests/client/test_config.py at main · devilcoder/python-sdk · GitHub
devilcoder
/
python-sdk
Public
forked from
modelcontextprotocol/python-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sdk
/
tests
/
client
/
test_config.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (36 loc) · 1.4 KB
Breadcrumbs
python-sdk
/
tests
/
client
/
test_config.py
Copy path
File metadata and controls
50 lines (36 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
json
import
subprocess
from
pathlib
import
Path
from
unittest
.
mock
import
patch
import
pytest
from
mcp
.
cli
.
claude
import
update_claude_config
@
pytest
.
fixture
def
temp_config_dir
(
tmp_path
:
Path
):
"""Create a temporary Claude config directory."""
config_dir
=
tmp_path
/
"Claude"
config_dir
.
mkdir
()
return
config_dir
@
pytest
.
fixture
def
mock_config_path
(
temp_config_dir
:
Path
):
"""Mock get_claude_config_path to return our temporary directory."""
with
patch
(
"mcp.cli.claude.get_claude_config_path"
,
return_value
=
temp_config_dir
):
yield
temp_config_dir
def
test_command_execution
(
mock_config_path
:
Path
):
"""Test that the generated command can actually be executed."""
# Setup
server_name
=
"test_server"
file_spec
=
"test_server.py:app"
# Update config
success
=
update_claude_config
(
file_spec
=
file_spec
,
server_name
=
server_name
)
assert
success
# Read the generated config
config_file
=
mock_config_path
/
"claude_desktop_config.json"
config
=
json
.
loads
(
config_file
.
read_text
())
# Get the command and args
server_config
=
config
[
"mcpServers"
][
server_name
]
command
=
server_config
[
"command"
]
args
=
server_config
[
"args"
]
test_args
=
[
command
]
+
args
+
[
"--help"
]
result
=
subprocess
.
run
(
test_args
,
capture_output
=
True
,
text
=
True
,
timeout
=
5
)
assert
result
.
returncode
==
0
assert
"usage"
in
result
.
stdout
.
lower
()
Back
|
FazBrowse Home
|
New Git URL