summaryrefslogtreecommitdiffstats
path: root/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
diff options
context:
space:
mode:
authorWangpan <hzwangpan@corp.netease.com>2013-02-19 13:14:06 +0800
committerWangpan <hzwangpan@corp.netease.com>2013-02-28 10:05:18 +0800
commit5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0 (patch)
tree5bddb615dcd2ea99e0cd4e58a7b0e66ec18e8b5f /nova/tests/api/openstack/compute/contrib/test_floating_ips.py
parentf86f9a8cb508da22bf02ac602710bacd8e2c1ff2 (diff)
downloadnova-5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0.tar.gz
nova-5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0.tar.xz
nova-5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0.zip
Return proper error messages while disassociating floating IP
Currently, when a floating IP is not associated with an instance, and if we try to disassociate it, a response likes "HTTP/1.1 404 Not Found" will be returned, it is not proper, so change it to "HTTP/1.1 422 Unprocessable Entity" with body likes '{"computeFault": {"message": "Floating ip 172.24.4.225 is not associated with instance a33857af-b18b-4b88-a5cc-7d84c7fd41c8.", "code": 422}}'. Fixes bug: #1129719 Change-Id: I18194ccf59edb5eb2bcd52a65f38d5632fef95d3
Diffstat (limited to 'nova/tests/api/openstack/compute/contrib/test_floating_ips.py')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_floating_ips.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
index 864ab7a9f..00759a7ef 100644
--- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
+++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
@@ -364,8 +364,9 @@ class FloatingIpTest(test.TestCase):
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
- rsp = self.manager._remove_floating_ip(req, 'test_inst', body)
- self.assertTrue(rsp.status_int == 404)
+ self.assertRaises(webob.exc.HTTPUnprocessableEntity,
+ self.manager._remove_floating_ip,
+ req, 'test_inst', body)
def test_floating_ip_associate_non_existent_ip(self):
def fake_network_api_associate(self, context, instance,
@@ -414,8 +415,9 @@ class FloatingIpTest(test.TestCase):
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
- rsp = self.manager._remove_floating_ip(req, wrong_uuid, body)
- self.assertTrue(rsp.status_int == 404)
+ self.assertRaises(webob.exc.HTTPUnprocessableEntity,
+ self.manager._remove_floating_ip,
+ req, wrong_uuid, body)
def test_floating_ip_disassociate_wrong_instance_id(self):
def get_instance_by_floating_ip_addr(self, context, address):
@@ -428,8 +430,9 @@ class FloatingIpTest(test.TestCase):
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
- rsp = self.manager._remove_floating_ip(req, 'test_inst', body)
- self.assertTrue(rsp.status_int == 404)
+ self.assertRaises(webob.exc.HTTPUnprocessableEntity,
+ self.manager._remove_floating_ip,
+ req, 'test_inst', body)
def test_floating_ip_disassociate_auto_assigned(self):
def fake_get_floating_ip_addr_auto_assigned(self, context, address):