add some negative tests for force_delete/restore
- test_force_delete_nonexistent_server_id - test_force_delete_server_invalid_state - test_restore_nonexistent_server_id - test_restore_server_invalid_state negative tests should stay in negative files of corresponding action. Change-Id: Icafcb1e17382f8856937e8e903650fb424b00a25
This commit is contained in:
parent
ffe8afe6ee
commit
aecc109742
@ -359,6 +359,36 @@ class ServersNegativeTestJSON(base.BaseV2ComputeTest):
|
||||
self.client.get_console_output,
|
||||
nonexistent_server, 10)
|
||||
|
||||
@attr(type=['negative', 'gate'])
|
||||
def test_force_delete_nonexistent_server_id(self):
|
||||
non_existent_server_id = str(uuid.uuid4())
|
||||
|
||||
self.assertRaises(exceptions.NotFound,
|
||||
self.client.force_delete_server,
|
||||
non_existent_server_id)
|
||||
|
||||
@attr(type=['negative', 'gate'])
|
||||
def test_force_delete_server_invalid_state(self):
|
||||
# we can only force-delete a server in 'soft-delete' state
|
||||
self.assertRaises(exceptions.Conflict,
|
||||
self.client.force_delete_server,
|
||||
self.server_id)
|
||||
|
||||
@attr(type=['negative', 'gate'])
|
||||
def test_restore_nonexistent_server_id(self):
|
||||
non_existent_server_id = str(uuid.uuid4())
|
||||
|
||||
self.assertRaises(exceptions.NotFound,
|
||||
self.client.restore_soft_deleted_server,
|
||||
non_existent_server_id)
|
||||
|
||||
@attr(type=['negative', 'gate'])
|
||||
def test_restore_server_invalid_state(self):
|
||||
# we can only restore-delete a server in 'soft-delete' state
|
||||
self.assertRaises(exceptions.Conflict,
|
||||
self.client.restore_soft_deleted_server,
|
||||
self.server_id)
|
||||
|
||||
|
||||
class ServersNegativeTestXML(ServersNegativeTestJSON):
|
||||
_interface = 'xml'
|
||||
|
@ -390,3 +390,11 @@ class ServersClientJSON(RestClient):
|
||||
(str(server_id), str(request_id)))
|
||||
body = json.loads(body)
|
||||
return resp, body['instanceAction']
|
||||
|
||||
def force_delete_server(self, server_id, **kwargs):
|
||||
"""Force delete a server."""
|
||||
return self.action(server_id, 'forceDelete', None, **kwargs)
|
||||
|
||||
def restore_soft_deleted_server(self, server_id, **kwargs):
|
||||
"""Restore a soft-deleted server."""
|
||||
return self.action(server_id, 'restore', None, **kwargs)
|
||||
|
@ -600,3 +600,11 @@ class ServersClientXML(RestClientXML):
|
||||
(server_id, request_id), self.headers)
|
||||
body = xml_to_json(etree.fromstring(body))
|
||||
return resp, body
|
||||
|
||||
def force_delete_server(self, server_id, **kwargs):
|
||||
"""Force delete a server."""
|
||||
return self.action(server_id, 'forceDelete', None, **kwargs)
|
||||
|
||||
def restore_soft_deleted_server(self, server_id, **kwargs):
|
||||
"""Restore a soft-deleted server."""
|
||||
return self.action(server_id, 'restore', None, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user