@@ -76,55 +76,55 @@ def test_backup_restore_invalid_host(self):
7676 @integration_test (scope = "component" )
7777 def test_backup_restore_no_backups (self ):
7878 """Test backup restore when no backups exist."""
79- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
79+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
8080 mock_backup_manager = MagicMock ()
8181 mock_backup_manager ._get_latest_backup .return_value = None
8282 mock_backup_class .return_value = mock_backup_manager
83-
83+
8484 with patch ('builtins.print' ) as mock_print :
8585 result = handle_mcp_backup_restore ('claude-desktop' )
86-
86+
8787 self .assertEqual (result , 1 )
88-
88+
8989 # Verify error message
9090 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
9191 self .assertTrue (any ("Error: No backups found for host 'claude-desktop'" in call for call in print_calls ))
9292
9393 @integration_test (scope = "component" )
9494 def test_backup_restore_dry_run (self ):
9595 """Test backup restore dry run functionality."""
96- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
96+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
9797 mock_backup_manager = MagicMock ()
9898 mock_backup_path = Path ("/test/backup.json" )
9999 mock_backup_manager ._get_latest_backup .return_value = mock_backup_path
100100 mock_backup_class .return_value = mock_backup_manager
101-
101+
102102 with patch ('builtins.print' ) as mock_print :
103103 result = handle_mcp_backup_restore ('claude-desktop' , dry_run = True )
104-
104+
105105 self .assertEqual (result , 0 )
106-
106+
107107 # Verify dry run output
108108 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
109109 self .assertTrue (any ("[DRY RUN] Would restore backup for host 'claude-desktop'" in call for call in print_calls ))
110110
111111 @integration_test (scope = "component" )
112112 def test_backup_restore_successful (self ):
113113 """Test successful backup restore operation."""
114- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
114+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
115115 mock_backup_manager = MagicMock ()
116116 mock_backup_path = Path ("/test/backup.json" )
117117 mock_backup_manager ._get_latest_backup .return_value = mock_backup_path
118118 mock_backup_manager .restore_backup .return_value = True
119119 mock_backup_class .return_value = mock_backup_manager
120-
120+
121121 with patch ('hatch.cli_hatch.request_confirmation' , return_value = True ):
122122 with patch ('builtins.print' ) as mock_print :
123123 result = handle_mcp_backup_restore ('claude-desktop' , auto_approve = True )
124-
124+
125125 self .assertEqual (result , 0 )
126126 mock_backup_manager .restore_backup .assert_called_once ()
127-
127+
128128 # Verify success message
129129 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
130130 self .assertTrue (any ("✓ Successfully restored backup" in call for call in print_calls ))
@@ -162,16 +162,16 @@ def test_backup_list_invalid_host(self):
162162 @integration_test (scope = "component" )
163163 def test_backup_list_no_backups (self ):
164164 """Test backup list when no backups exist."""
165- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
165+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
166166 mock_backup_manager = MagicMock ()
167167 mock_backup_manager .list_backups .return_value = []
168168 mock_backup_class .return_value = mock_backup_manager
169-
169+
170170 with patch ('builtins.print' ) as mock_print :
171171 result = handle_mcp_backup_list ('claude-desktop' )
172-
172+
173173 self .assertEqual (result , 0 )
174-
174+
175175 # Verify no backups message
176176 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
177177 self .assertTrue (any ("No backups found for host 'claude-desktop'" in call for call in print_calls ))
@@ -180,24 +180,25 @@ def test_backup_list_no_backups(self):
180180 def test_backup_list_detailed_output (self ):
181181 """Test backup list with detailed output format."""
182182 from hatch .mcp_host_config .backup import BackupInfo
183-
184- # Create mock backup info
183+
184+ # Create mock backup info with proper attributes
185185 mock_backup = MagicMock (spec = BackupInfo )
186+ mock_backup .file_path = MagicMock ()
186187 mock_backup .file_path .name = "mcp.json.claude-desktop.20250922_143000_123456"
187188 mock_backup .timestamp = datetime (2025 , 9 , 22 , 14 , 30 , 0 )
188189 mock_backup .file_size = 1024
189190 mock_backup .age_days = 5
190-
191- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
191+
192+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
192193 mock_backup_manager = MagicMock ()
193194 mock_backup_manager .list_backups .return_value = [mock_backup ]
194195 mock_backup_class .return_value = mock_backup_manager
195-
196+
196197 with patch ('builtins.print' ) as mock_print :
197198 result = handle_mcp_backup_list ('claude-desktop' , detailed = True )
198-
199+
199200 self .assertEqual (result , 0 )
200-
201+
201202 # Verify detailed table output
202203 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
203204 self .assertTrue (any ("Backup File" in call for call in print_calls ))
@@ -238,43 +239,49 @@ def test_backup_clean_no_criteria(self):
238239 def test_backup_clean_dry_run (self ):
239240 """Test backup clean dry run functionality."""
240241 from hatch .mcp_host_config .backup import BackupInfo
241-
242- # Create mock backup info
242+
243+ # Create mock backup info with proper attributes
243244 mock_backup = MagicMock (spec = BackupInfo )
244- mock_backup .file_path .name = "old_backup.json"
245245 mock_backup .file_path = Path ("/test/old_backup.json" )
246246 mock_backup .age_days = 35
247-
248- with patch ('hatch.cli_hatch .MCPHostConfigBackupManager' ) as mock_backup_class :
247+
248+ with patch ('hatch.mcp_host_config.backup .MCPHostConfigBackupManager' ) as mock_backup_class :
249249 mock_backup_manager = MagicMock ()
250250 mock_backup_manager .list_backups .return_value = [mock_backup ]
251251 mock_backup_class .return_value = mock_backup_manager
252-
252+
253253 with patch ('builtins.print' ) as mock_print :
254254 result = handle_mcp_backup_clean ('claude-desktop' , older_than_days = 30 , dry_run = True )
255-
255+
256256 self .assertEqual (result , 0 )
257-
257+
258258 # Verify dry run output
259259 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
260260 self .assertTrue (any ("[DRY RUN] Would clean" in call for call in print_calls ))
261261
262262 @integration_test (scope = "component" )
263263 def test_backup_clean_successful (self ):
264264 """Test successful backup clean operation."""
265- with patch ('hatch.cli_hatch.MCPHostConfigBackupManager' ) as mock_backup_class :
265+ from hatch .mcp_host_config .backup import BackupInfo
266+
267+ # Create mock backup with proper attributes
268+ mock_backup = MagicMock (spec = BackupInfo )
269+ mock_backup .file_path = Path ("/test/backup.json" )
270+ mock_backup .age_days = 35
271+
272+ with patch ('hatch.mcp_host_config.backup.MCPHostConfigBackupManager' ) as mock_backup_class :
266273 mock_backup_manager = MagicMock ()
267- mock_backup_manager .list_backups .return_value = [MagicMock () ] # Some backups exist
274+ mock_backup_manager .list_backups .return_value = [mock_backup ] # Some backups exist
268275 mock_backup_manager .clean_backups .return_value = 3 # 3 backups cleaned
269276 mock_backup_class .return_value = mock_backup_manager
270-
277+
271278 with patch ('hatch.cli_hatch.request_confirmation' , return_value = True ):
272279 with patch ('builtins.print' ) as mock_print :
273280 result = handle_mcp_backup_clean ('claude-desktop' , older_than_days = 30 , auto_approve = True )
274-
281+
275282 self .assertEqual (result , 0 )
276283 mock_backup_manager .clean_backups .assert_called_once ()
277-
284+
278285 # Verify success message
279286 print_calls = [call [0 ][0 ] for call in mock_print .call_args_list ]
280287 self .assertTrue (any ("✓ Successfully cleaned 3 backup(s)" in call for call in print_calls ))
0 commit comments