From 81093c0ab703a79e7173fe38f69318e3b1b62d9c Mon Sep 17 00:00:00 2001 From: Haiwei Xu Date: Fri, 12 Sep 2014 17:41:07 +0900 Subject: [PATCH] Add multinic API unit test Multinic api unit test is not sufficient, so this patch adds a testcase for removing a fixed IP when the IP is not found. Change-Id: Ice04806269a92244bd068b90e9934eaedb17a1b4 --- .../openstack/compute/contrib/test_multinic.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nova/tests/api/openstack/compute/contrib/test_multinic.py b/nova/tests/api/openstack/compute/contrib/test_multinic.py index bd64819b3cba..d8dd3d03c073 100644 --- a/nova/tests/api/openstack/compute/contrib/test_multinic.py +++ b/nova/tests/api/openstack/compute/contrib/test_multinic.py @@ -171,6 +171,21 @@ class FixedIpTestV21(test.NoDBTestCase): resp = req.get_response(self.app) self.assertEqual(400, resp.status_int) + @mock.patch.object(compute.api.API, 'remove_fixed_ip', + side_effect=exception.FixedIpNotFoundForSpecificInstance( + instance_uuid=UUID, ip='10.10.10.1')) + def test_remove_fixed_ip_not_found(self, _remove_fixed_ip): + + body = {'remove_fixed_ip': {'address': '10.10.10.1'}} + req = webob.Request.blank( + self._get_url() + '/servers/%s/action' % UUID) + req.method = 'POST' + req.body = jsonutils.dumps(body) + req.headers['content-type'] = 'application/json' + + resp = req.get_response(self.app) + self.assertEqual(400, resp.status_int) + class FixedIpTestV2(FixedIpTestV21): def setUp(self):