Add unit test for add_floating_ip API

Currently, add_floating_ip API has no unit test for body's key test,
this patch adds the test cases.

Change-Id: I32a32514c68fcd8717011d37724a20993aa8ed20
This commit is contained in:
Haiwei Xu 2014-09-12 15:46:59 +09:00
parent 9a1abd3b66
commit 3a164de734
1 changed files with 14 additions and 0 deletions

View File

@ -511,6 +511,20 @@ class FloatingIpTest(test.TestCase):
self.manager._add_floating_ip, req, 'test_inst',
body)
def test_associate_floating_ip_bad_address_key(self):
body = dict(addFloatingIp=dict(bad_address='10.10.10.11'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
self.assertRaises(webob.exc.HTTPBadRequest,
self.manager._add_floating_ip, req, 'test_inst',
body)
def test_associate_floating_ip_bad_addfloatingip_key(self):
body = dict(bad_addFloatingIp=dict(address='10.10.10.11'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')
self.assertRaises(webob.exc.HTTPBadRequest,
self.manager._add_floating_ip, req, 'test_inst',
body)
def test_floating_ip_disassociate(self):
def get_instance_by_floating_ip_addr(self, context, address):
if address == '10.10.10.10':