def test05_destroy_vm(self): """Happy path test to verify destruction of VM instances.""" # Construct mock return object. json_body = '{"ok": true}' resp = _HttpResponse(200, json_body) # Patch with patch.object(service, '_make_request', return_value=resp) as mock_func: service.destroy_vm(self.vmpooler_url, self.hostname, self.auth_token)
def test05_destroy_vm(self): """Happy path test to verify destruction of VM instances.""" # Construct mock return object. json_body = '{"ok": true}' resp = _HttpResponse(200, json_body) # Patch with patch.object(service, '_make_request', return_value=resp) as mock_func: service.destroy_vm(self.vmpooler_hostname, self.hostname, self.auth_token)
def test06_destroy_vm_neg(self): """Negative test case for attempting to destroy non-existent VM instance.""" # Construct mock return object. json_body = '{"ok": false}' resp = _HttpResponse(404, json_body) # Patch with patch.object(service, '_make_request', return_value=resp) as mock_func: with self.assertRaises(RuntimeError) as cm: service.destroy_vm(self.vmpooler_url, self.hostname, self.auth_token) excep = cm.exception self.assertEqual(excep.msg, 'The VM is already destroyed or wrong VM name provided!')
def test06_destroy_vm_neg(self): """Negative test case for attempting to destroy non-existent VM instance.""" # Construct mock return object. json_body = '{"ok": false}' resp = _HttpResponse(404, json_body) # Patch with patch.object(service, '_make_request', return_value=resp) as mock_func: with self.assertRaises(RuntimeError) as cm: service.destroy_vm(self.vmpooler_hostname, self.hostname, self.auth_token) excep = cm.exception self.assertEqual( excep.msg, 'The VM is already destroyed or wrong VM name provided!')