1010"""
1111
1212import unittest
13- from unittest .mock import patch , MagicMock
13+ from unittest .mock import patch , MagicMock , ANY
1414import sys
1515from pathlib import Path
1616
@@ -218,7 +218,7 @@ def test_remove_argument_parsing(self):
218218 with patch ('hatch.cli_hatch.handle_mcp_remove_server' , return_value = 0 ) as mock_handler :
219219 try :
220220 main ()
221- mock_handler .assert_called_once_with ('old-server' , 'vscode' , None , True , False , True )
221+ mock_handler .assert_called_once_with (ANY , 'old-server' , 'vscode' , None , True , False , True )
222222 except SystemExit as e :
223223 self .assertEqual (e .code , 0 )
224224
@@ -317,7 +317,7 @@ def test_remove_server_argument_parsing(self):
317317 with patch ('hatch.cli_hatch.handle_mcp_remove_server' , return_value = 0 ) as mock_handler :
318318 try :
319319 main ()
320- mock_handler .assert_called_once_with ('test-server' , 'claude-desktop' , None , True , False , False )
320+ mock_handler .assert_called_once_with (ANY , 'test-server' , 'claude-desktop' , None , True , False , False )
321321 except SystemExit as e :
322322 self .assertEqual (e .code , 0 )
323323
@@ -329,10 +329,11 @@ def test_remove_server_multi_host(self):
329329 mock_manager .remove_server .return_value = MagicMock (success = True , backup_path = None )
330330 mock_manager_class .return_value = mock_manager
331331
332- with patch ('builtins.print' ) as mock_print :
333- result = handle_mcp_remove_server ('test-server' , 'claude-desktop,cursor' , auto_approve = True )
332+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
333+ with patch ('builtins.print' ) as mock_print :
334+ result = handle_mcp_remove_server (mock_env_manager .return_value , 'test-server' , 'claude-desktop,cursor' , auto_approve = True )
334335
335- self .assertEqual (result , 0 )
336+ self .assertEqual (result , 0 )
336337 self .assertEqual (mock_manager .remove_server .call_count , 2 )
337338
338339 # Verify success messages
@@ -343,10 +344,11 @@ def test_remove_server_multi_host(self):
343344 @integration_test (scope = "component" )
344345 def test_remove_server_no_host_specified (self ):
345346 """Test remove server with no host specified."""
346- with patch ('builtins.print' ) as mock_print :
347- result = handle_mcp_remove_server ('test-server' )
347+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
348+ with patch ('builtins.print' ) as mock_print :
349+ result = handle_mcp_remove_server (mock_env_manager .return_value , 'test-server' )
348350
349- self .assertEqual (result , 1 )
351+ self .assertEqual (result , 1 )
350352
351353 # Verify error message
352354 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
@@ -355,10 +357,11 @@ def test_remove_server_no_host_specified(self):
355357 @integration_test (scope = "component" )
356358 def test_remove_server_dry_run (self ):
357359 """Test remove server dry run functionality."""
358- with patch ('builtins.print' ) as mock_print :
359- result = handle_mcp_remove_server ('test-server' , 'claude-desktop' , dry_run = True )
360+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
361+ with patch ('builtins.print' ) as mock_print :
362+ result = handle_mcp_remove_server (mock_env_manager .return_value , 'test-server' , 'claude-desktop' , dry_run = True )
360363
361- self .assertEqual (result , 0 )
364+ self .assertEqual (result , 0 )
362365
363366 # Verify dry run output
364367 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
@@ -378,7 +381,7 @@ def test_remove_host_argument_parsing(self):
378381 with patch ('hatch.cli_hatch.handle_mcp_remove_host' , return_value = 0 ) as mock_handler :
379382 try :
380383 main ()
381- mock_handler .assert_called_once_with ('claude-desktop' , False , False , True )
384+ mock_handler .assert_called_once_with (ANY , 'claude-desktop' , False , False , True )
382385 except SystemExit as e :
383386 self .assertEqual (e .code , 0 )
384387
@@ -393,10 +396,11 @@ def test_remove_host_successful(self):
393396 mock_manager .remove_host_configuration .return_value = mock_result
394397 mock_manager_class .return_value = mock_manager
395398
396- with patch ('builtins.print' ) as mock_print :
397- result = handle_mcp_remove_host ('claude-desktop' , auto_approve = True )
399+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
400+ with patch ('builtins.print' ) as mock_print :
401+ result = handle_mcp_remove_host (mock_env_manager .return_value , 'claude-desktop' , auto_approve = True )
398402
399- self .assertEqual (result , 0 )
403+ self .assertEqual (result , 0 )
400404 mock_manager .remove_host_configuration .assert_called_once_with (
401405 hostname = 'claude-desktop' , no_backup = False
402406 )
@@ -408,10 +412,11 @@ def test_remove_host_successful(self):
408412 @integration_test (scope = "component" )
409413 def test_remove_host_invalid_host (self ):
410414 """Test remove host with invalid host type."""
411- with patch ('builtins.print' ) as mock_print :
412- result = handle_mcp_remove_host ('invalid-host' )
415+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
416+ with patch ('builtins.print' ) as mock_print :
417+ result = handle_mcp_remove_host (mock_env_manager .return_value , 'invalid-host' )
413418
414- self .assertEqual (result , 1 )
419+ self .assertEqual (result , 1 )
415420
416421 # Verify error message
417422 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
@@ -420,10 +425,11 @@ def test_remove_host_invalid_host(self):
420425 @integration_test (scope = "component" )
421426 def test_remove_host_dry_run (self ):
422427 """Test remove host dry run functionality."""
423- with patch ('builtins.print' ) as mock_print :
424- result = handle_mcp_remove_host ('claude-desktop' , dry_run = True )
428+ with patch ('hatch.cli_hatch.HatchEnvironmentManager' ) as mock_env_manager :
429+ with patch ('builtins.print' ) as mock_print :
430+ result = handle_mcp_remove_host (mock_env_manager .return_value , 'claude-desktop' , dry_run = True )
425431
426- self .assertEqual (result , 0 )
432+ self .assertEqual (result , 0 )
427433
428434 # Verify dry run output
429435 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
0 commit comments