Merge "add some negative tests for force_delete/restore"

This commit is contained in:
Jenkins 2013-11-07 09:55:49 +00:00 committed by Gerrit Code Review
commit dadd85c971
3 changed files with 46 additions and 0 deletions

View File

@ -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'

View File

@ -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)

View File

@ -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)