Skip to content

Commit

Permalink
Add two tests for resize action in ServerActionsControllerTest.
Browse files Browse the repository at this point in the history
Add test_resize_not_found for NotFound;
and test_resize_with_too_many_instances for TooManyInstances.

Fix bug #1089417

Change-Id: I18dda1129e1bb3d411bb8a5dab9474d67fcb18fd
  • Loading branch information
xychu committed Jan 5, 2013
1 parent 8be4773 commit 351745d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion nova/tests/api/openstack/compute/test_server_actions.py
Expand Up @@ -40,7 +40,7 @@
INSTANCE_IDS = {FAKE_UUID: 1}


def return_server_not_found(context, uuid):
def return_server_not_found(*arg, **kwarg):
raise exception.NotFound()


Expand Down Expand Up @@ -604,6 +604,29 @@ def test_resize_server_no_flavor_ref(self):
self.controller._action_resize,
req, FAKE_UUID, body)

def test_resize_with_server_not_found(self):
body = dict(resize=dict(flavorRef="http://localhost/3"))

self.stubs.Set(compute_api.API, 'get', return_server_not_found)

req = fakes.HTTPRequest.blank(self.url)
self.assertRaises(webob.exc.HTTPNotFound,
self.controller._action_resize,
req, FAKE_UUID, body)

def test_resize_with_too_many_instances(self):
body = dict(resize=dict(flavorRef="http://localhost/3"))

def fake_resize(*args, **kwargs):
raise exception.TooManyInstances(message="TooManyInstance")

self.stubs.Set(compute_api.API, 'resize', fake_resize)

req = fakes.HTTPRequest.blank(self.url)
self.assertRaises(exception.TooManyInstances,
self.controller._action_resize,
req, FAKE_UUID, body)

def test_resize_raises_conflict_on_invalid_state(self):
body = dict(resize=dict(flavorRef="http://localhost/3"))

Expand Down

0 comments on commit 351745d

Please sign in to comment.