11import json
22import subprocess
3- from pathlib import Path
43from unittest .mock import patch
54
65import pytest
@@ -15,42 +14,39 @@ def temp_config_dir(tmp_path):
1514 config_dir .mkdir ()
1615 return config_dir
1716
17+
1818@pytest .fixture
1919def mock_config_path (temp_config_dir ):
2020 """Mock get_claude_config_path to return our temporary directory."""
21- with patch (' mcp.cli.claude.get_claude_config_path' , return_value = temp_config_dir ):
21+ with patch (" mcp.cli.claude.get_claude_config_path" , return_value = temp_config_dir ):
2222 yield temp_config_dir
2323
24+
2425def test_command_execution (mock_config_path ):
2526 """Test that the generated command can actually be executed."""
2627 # Setup
2728 server_name = "test_server"
2829 file_spec = "test_server.py:app"
29-
30+
3031 # Update config
3132 success = update_claude_config (
3233 file_spec = file_spec ,
3334 server_name = server_name ,
3435 )
3536 assert success
36-
37+
3738 # Read the generated config
3839 config_file = mock_config_path / "claude_desktop_config.json"
3940 config = json .loads (config_file .read_text ())
40-
41+
4142 # Get the command and args
4243 server_config = config ["mcpServers" ][server_name ]
4344 command = server_config ["command" ]
4445 args = server_config ["args" ]
4546
4647 test_args = [command ] + args + ["--help" ]
47-
48- result = subprocess .run (
49- test_args ,
50- capture_output = True ,
51- text = True ,
52- timeout = 5
53- )
54-
48+
49+ result = subprocess .run (test_args , capture_output = True , text = True , timeout = 5 )
50+
5551 assert result .returncode == 0
56- assert "usage" in result .stdout .lower ()
52+ assert "usage" in result .stdout .lower ()
0 commit comments