Skip to content

Commit 5ecd958

Browse files
niechenclaude
andcommitted
test: add assertion for remove_server method call in client edit test
- Enhanced test_client_edit_non_interactive_remove_server to verify that client_manager.remove_server is called with the correct prefixed server name - Added proper mock setup for MCPM-managed server configuration - Ensures the removal operation is actually triggered as intended - Also includes automatic formatting fixes in test_profile_commands.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6b149a3 commit 5ecd958

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tests/test_client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,13 @@ def test_client_edit_non_interactive_remove_server(monkeypatch):
443443
mock_client_manager = Mock()
444444
mock_client_manager.is_client_installed = Mock(return_value=True)
445445
mock_client_manager.config_path = "/path/to/config.json"
446-
mock_client_manager.get_servers.return_value = {"existing-server": Mock()}
446+
# Mock an MCPM-managed server in client config
447+
existing_mcpm_server = Mock()
448+
existing_mcpm_server.command = "mcpm"
449+
existing_mcpm_server.args = ["run", "existing-server"]
450+
mock_client_manager.get_servers.return_value = {"mcpm_existing-server": existing_mcpm_server}
447451
mock_client_manager.update_servers.return_value = None
452+
mock_client_manager.remove_server.return_value = None
448453

449454
monkeypatch.setattr("mcpm.commands.client.ClientRegistry.get_client_manager", Mock(return_value=mock_client_manager))
450455
monkeypatch.setattr("mcpm.commands.client.ClientRegistry.get_client_info", Mock(return_value={"name": "Cursor"}))
@@ -463,9 +468,12 @@ def test_client_edit_non_interactive_remove_server(monkeypatch):
463468
"--remove-server", "existing-server"
464469
])
465470

466-
# The command runs without crashing, even if the server wasn't in the client
471+
# The command runs without crashing and removes the server
467472
assert result.exit_code == 0
468473
assert "Cursor Configuration Management" in result.output
474+
475+
# Verify that remove_server was called with the prefixed server name
476+
mock_client_manager.remove_server.assert_called_with("mcpm_existing-server")
469477

470478

471479
def test_client_edit_non_interactive_set_servers(monkeypatch):

tests/test_profile_commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_profile_edit_non_interactive_remove_server(monkeypatch):
6161
# Mock GlobalConfigManager (needed for server validation)
6262
mock_global_config = Mock()
6363
mock_global_config.list_servers.return_value = {
64-
"server1": server1,
64+
"server1": server1,
6565
"server2": server2
6666
}
6767
monkeypatch.setattr("mcpm.commands.profile.edit.global_config_manager", mock_global_config)
@@ -246,7 +246,7 @@ def test_profile_edit_interactive_fallback(monkeypatch):
246246
mock_profile_config.get_profile.return_value = [existing_server]
247247
monkeypatch.setattr("mcpm.commands.profile.edit.profile_config_manager", mock_profile_config)
248248

249-
# Mock GlobalConfigManager
249+
# Mock GlobalConfigManager
250250
mock_global_config = Mock()
251251
mock_global_config.list_servers.return_value = {"existing-server": existing_server}
252252
monkeypatch.setattr("mcpm.commands.profile.edit.global_config_manager", mock_global_config)
@@ -281,7 +281,7 @@ def test_profile_inspect_non_interactive(monkeypatch):
281281
class MockCompletedProcess:
282282
def __init__(self, returncode=0):
283283
self.returncode = returncode
284-
284+
285285
mock_subprocess = Mock()
286286
mock_subprocess.run.return_value = MockCompletedProcess(0)
287287
monkeypatch.setattr("mcpm.commands.profile.inspect.subprocess", mock_subprocess)

0 commit comments

Comments
 (0)