diff options
| author | Sulochan Acharya <sulochan@gmail.com> | 2012-08-21 11:53:04 -0500 |
|---|---|---|
| committer | Sulochan Acharya <sulochan@gmail.com> | 2012-08-22 09:13:03 -0500 |
| commit | 5dc0039c85957502db36b7da5558f9449cd03ada (patch) | |
| tree | ee771b194da24755ecc0552b59c32e9d30ed18e9 /nova | |
| parent | b090bdd0887317bb4f1f2a8ecec577b16fb94363 (diff) | |
Adds missing assertion to FloatingIP tests
Adding assertions to some tests to ensure that we catch the
return status_int. Found that test_floating_ip_disassociate would
actually fail the test if status_int was caught. Adding the
get_instance_by_floating_ip_addr stub to to the disassociate test
to return the test instance on IP match. This is required because
get_instance_by_floating_ip_addr is stubbed in setup to return None.
Fixes bug 1039432.
Also making a minor change in test_bad_param_in_remove_floating_ip
which should call _remove_floating_ip rather than _add_floating_ip.
Change-Id: Id43f785bb0e6b7405e2d292292c4126d7ed656cb
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_floating_ips.py | 15 |
1 files changed, 12 insertions, 3 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 ce43c0ffa..e1602f832 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -304,13 +304,22 @@ class FloatingIpTest(test.TestCase): body = dict(addFloatingIp=dict(address=self.floating_ip)) req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') - self.manager._add_floating_ip(req, 'test_inst', body) + rsp = self.manager._add_floating_ip(req, 'test_inst', body) + self.assertTrue(rsp.status_int == 202) def test_floating_ip_disassociate(self): + def get_instance_by_floating_ip_addr(self, context, address): + if address == '10.10.10.10': + return 'test_inst' + + self.stubs.Set(network.api.API, "get_instance_id_by_floating_address", + get_instance_by_floating_ip_addr) + body = dict(removeFloatingIp=dict(address='10.10.10.10')) req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') - self.manager._remove_floating_ip(req, 'test_inst', body) + rsp = self.manager._remove_floating_ip(req, 'test_inst', body) + self.assertTrue(rsp.status_int == 202) def test_floating_ip_disassociate_missing(self): body = dict(removeFloatingIp=dict(address='10.10.10.10')) @@ -326,7 +335,7 @@ class FloatingIpTest(test.TestCase): req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') self.assertRaises(webob.exc.HTTPBadRequest, - self.manager._add_floating_ip, req, 'test_inst', + self.manager._remove_floating_ip, req, 'test_inst', body) def test_missing_dict_param_in_remove_floating_ip(self): |
