def test_delete_snapshot(self): ''' Test parallels.delete_snapshot ''' name = 'macvm' snap_name = 'kaon' snap_id = 'c2eab062-a635-4ccd-b9ae-998370f898b5' mock_snap_name = MagicMock(return_value=snap_id) with patch.object(parallels, '_validate_snap_name', mock_snap_name): mock_delete = MagicMock(return_value='') with patch.object(parallels, 'prlctl', mock_delete): parallels.delete_snapshot(name, snap_name) mock_delete.assert_called_once_with('snapshot-delete', [name, '--id', snap_id], runas=None)
def test_delete_snapshot(self): """ Test parallels.delete_snapshot """ delete_message = ( "Delete the snapshot...\nThe snapshot has been successfully deleted." ) # Validate single ID name = "macvm" snap_name = "kaon" snap_id = "c2eab062-a635-4ccd-b9ae-998370f898b5" mock_snap_name = MagicMock(return_value=snap_id) with patch.object(parallels, "_validate_snap_name", mock_snap_name): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, "prlctl", mock_delete): ret = parallels.delete_snapshot(name, snap_name) self.assertEqual(ret, delete_message) mock_delete.assert_called_once_with("snapshot-delete", [name, "--id", snap_id], runas=None) # Validate multiple IDs name = "macvm" snap_name = "higgs doublet" snap_ids = [ "c2eab062-a635-4ccd-b9ae-998370f898b5", "8aca07c5-a0e1-4dcb-ba75-cb154d46d516", ] mock_snap_ids = MagicMock(return_value=snap_ids) with patch.object(parallels, "_validate_snap_name", mock_snap_ids): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, "prlctl", mock_delete): ret = parallels.delete_snapshot(name, snap_name, all=True) mock_ret = { snap_ids[0]: delete_message, snap_ids[1]: delete_message } self.assertDictEqual(ret, mock_ret) mock_delete.assert_any_call("snapshot-delete", [name, "--id", snap_ids[0]], runas=None) mock_delete.assert_any_call("snapshot-delete", [name, "--id", snap_ids[1]], runas=None)
def test_delete_snapshot(self): ''' Test parallels.delete_snapshot ''' delete_message = ('Delete the snapshot...\n' 'The snapshot has been successfully deleted.') # Validate single ID name = 'macvm' snap_name = 'kaon' snap_id = 'c2eab062-a635-4ccd-b9ae-998370f898b5' mock_snap_name = MagicMock(return_value=snap_id) with patch.object(parallels, '_validate_snap_name', mock_snap_name): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, 'prlctl', mock_delete): ret = parallels.delete_snapshot(name, snap_name) self.assertEqual(ret, delete_message) mock_delete.assert_called_once_with('snapshot-delete', [name, '--id', snap_id], runas=None) # Validate multiple IDs name = 'macvm' snap_name = 'higgs doublet' snap_ids = [ 'c2eab062-a635-4ccd-b9ae-998370f898b5', '8aca07c5-a0e1-4dcb-ba75-cb154d46d516' ] mock_snap_ids = MagicMock(return_value=snap_ids) with patch.object(parallels, '_validate_snap_name', mock_snap_ids): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, 'prlctl', mock_delete): ret = parallels.delete_snapshot(name, snap_name, all=True) mock_ret = { snap_ids[0]: delete_message, snap_ids[1]: delete_message } self.assertDictEqual(ret, mock_ret) mock_delete.assert_any_call('snapshot-delete', [name, '--id', snap_ids[0]], runas=None) mock_delete.assert_any_call('snapshot-delete', [name, '--id', snap_ids[1]], runas=None)
def test_delete_snapshot(self): ''' Test parallels.delete_snapshot ''' delete_message = ('Delete the snapshot...\n' 'The snapshot has been successfully deleted.') # Validate single ID name = 'macvm' snap_name = 'kaon' snap_id = 'c2eab062-a635-4ccd-b9ae-998370f898b5' mock_snap_name = MagicMock(return_value=snap_id) with patch.object(parallels, '_validate_snap_name', mock_snap_name): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, 'prlctl', mock_delete): ret = parallels.delete_snapshot(name, snap_name) self.assertEqual(ret, delete_message) mock_delete.assert_called_once_with('snapshot-delete', [name, '--id', snap_id], runas=None) # Validate multiple IDs name = 'macvm' snap_name = 'higgs doublet' snap_ids = ['c2eab062-a635-4ccd-b9ae-998370f898b5', '8aca07c5-a0e1-4dcb-ba75-cb154d46d516'] mock_snap_ids = MagicMock(return_value=snap_ids) with patch.object(parallels, '_validate_snap_name', mock_snap_ids): mock_delete = MagicMock(return_value=delete_message) with patch.object(parallels, 'prlctl', mock_delete): ret = parallels.delete_snapshot(name, snap_name, all=True) mock_ret = {snap_ids[0]: delete_message, snap_ids[1]: delete_message} self.assertDictEqual(ret, mock_ret) mock_delete.assert_any_call('snapshot-delete', [name, '--id', snap_ids[0]], runas=None) mock_delete.assert_any_call('snapshot-delete', [name, '--id', snap_ids[1]], runas=None)