def test_destroy_vm_raise_vim_fault(self): exception = vim.fault.VimFault() exception.msg = 'vim.fault.VimFault' self.mock_vm_ref.Destroy_Task = MagicMock(side_effect=exception) with self.assertRaises(VMwareApiError) as exc: vmware.delete_vm(self.mock_vm_ref) self.assertEqual(exc.exception.strerror, 'vim.fault.VimFault')
def test_destroy_vm_raise_runtime_fault(self): exception = vmodl.RuntimeFault() exception.msg = 'vmodl.RuntimeFault' self.mock_vm_ref.Destroy_Task = MagicMock(side_effect=exception) with self.assertRaises(VMwareRuntimeError) as exc: vmware.delete_vm(self.mock_vm_ref) self.assertEqual(exc.exception.strerror, 'vmodl.RuntimeFault')
def test_destroy_vm_wait_for_task(self): mock_wait_for_task = MagicMock() with patch('salt.utils.vmware.get_managed_object_name', MagicMock(return_value='my_vm')): with patch('salt.utils.vmware.wait_for_task', mock_wait_for_task): vmware.delete_vm(self.mock_vm_ref) mock_wait_for_task.assert_called_once_with(self.mock_task, 'my_vm', 'Destroy Task')
def test_destroy_vm_task_call(self): vmware.delete_vm(self.mock_vm_ref) self.mock_vm_destroy_task.assert_called_once()