From: Cedric Brandily Date: Mon, 12 Jan 2015 13:10:03 +0000 (+0000) Subject: Correct _test_delete_ports_by_device_id_second_call_failure X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=58c624fad3485e7604f1fb4a6616d2b09c03d8af;p=openstack-build%2Fneutron-build.git Correct _test_delete_ports_by_device_id_second_call_failure Currently the test assumes delete_ports_by_device_id deletes ports in the order they were created but nothing ensures it. This change updates _test_delete_ports_by_device_id_second_call_failure to avoid such (incorrect) assumption. The assumption is in general broken in daughter change which adds a unique constraint on Port table. Change-Id: I387354eb8c02b614321ace5a105253d7504d5119 --- diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index 3bce709d5..576926f99 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -451,15 +451,19 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase, res = req.get_response(self._api_for_resource(collection)) self.assertEqual(res.status_int, expected_code) - def _show(self, resource, id, - expected_code=webob.exc.HTTPOk.code, - neutron_context=None): + def _show_response(self, resource, id, neutron_context=None): req = self.new_show_request(resource, id) if neutron_context: # create a specific auth context for this request req.environ['neutron.context'] = neutron_context - res = req.get_response(self._api_for_resource(resource)) - self.assertEqual(res.status_int, expected_code) + return req.get_response(self._api_for_resource(resource)) + + def _show(self, resource, id, + expected_code=webob.exc.HTTPOk.code, + neutron_context=None): + res = self._show_response(resource, id, + neutron_context=neutron_context) + self.assertEqual(expected_code, res.status_int) return self.deserialize(self.fmt, res) def _update(self, resource, id, new_data, @@ -1781,10 +1785,11 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s self.assertRaises(n_exc.NeutronException, plugin.delete_ports_by_device_id, ctx, 'owner1', network_id) - self._show('ports', p1['port']['id'], - expected_code=webob.exc.HTTPNotFound.code) - self._show('ports', p2['port']['id'], - expected_code=webob.exc.HTTPOk.code) + statuses = { + self._show_response('ports', p['port']['id']).status_int + for p in [p1, p2]} + expected = {webob.exc.HTTPNotFound.code, webob.exc.HTTPOk.code} + self.assertEqual(expected, statuses) self._show('ports', p3['port']['id'], expected_code=webob.exc.HTTPOk.code)