diff options
author | Xiangyang Chu <xychu2008@gmail.com> | 2012-12-20 16:52:00 +0800 |
---|---|---|
committer | Xiangyang Chu <xychu2008@gmail.com> | 2013-01-05 13:34:55 +0800 |
commit | 351745d3d359fe6ba24cf7dd2283c6fdc670ec57 (patch) | |
tree | 5b128d753c9f4eaa6a2bb9946175ed3e0b73d94d | |
parent | 8be47738aedb809b9d64559aeba821e17796a6a8 (diff) | |
download | nova-351745d3d359fe6ba24cf7dd2283c6fdc670ec57.tar.gz nova-351745d3d359fe6ba24cf7dd2283c6fdc670ec57.tar.xz nova-351745d3d359fe6ba24cf7dd2283c6fdc670ec57.zip |
Add two tests for resize action in ServerActionsControllerTest.
Add test_resize_not_found for NotFound;
and test_resize_with_too_many_instances for TooManyInstances.
Fix bug #1089417
Change-Id: I18dda1129e1bb3d411bb8a5dab9474d67fcb18fd
-rw-r--r-- | nova/tests/api/openstack/compute/test_server_actions.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/nova/tests/api/openstack/compute/test_server_actions.py b/nova/tests/api/openstack/compute/test_server_actions.py index 414d70c7c..3c2d795cd 100644 --- a/nova/tests/api/openstack/compute/test_server_actions.py +++ b/nova/tests/api/openstack/compute/test_server_actions.py @@ -40,7 +40,7 @@ FAKE_UUID = fakes.FAKE_UUID INSTANCE_IDS = {FAKE_UUID: 1} -def return_server_not_found(context, uuid): +def return_server_not_found(*arg, **kwarg): raise exception.NotFound() @@ -604,6 +604,29 @@ class ServerActionsControllerTest(test.TestCase): 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")) |