From ccbabbeebf830a02127f5d5e544947b9b11a87b0 Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Thu, 5 Mar 2015 08:37:24 -0800 Subject: [PATCH] Fix test tautology for DVR Change 17cae2c added tests that pass regardless of whatever code they are supposed to validate. If one asked for a bad example of how not to write/review test, change 17cae2c would be one of it. This fix is my way to repent. Change-Id: Ibb27f24380beab99388c0a6dc187b75e0852761e --- neutron/tests/unit/db/test_l3_dvr_db.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index 103e100cfa4..2b7fab93553 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -159,15 +159,16 @@ class L3DvrTestCase(testlib_api.SqlTestCase): with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp: plugin = mock.Mock() gp.return_value = plugin - plugin.get_ports.return_value = [port] - plugin.assertRaises(l3.L3PortInUse, - plugin.delete_port, - self.ctx, - 'my_port_id') + plugin._get_port.return_value = port + self.assertRaises(l3.L3PortInUse, + self.mixin.prevent_l3_port_deletion, + self.ctx, + port['id']) def test_prevent_delete_floatingip_agent_gateway_port(self): port = { 'id': 'my_port_id', + 'fixed_ips': mock.ANY, 'device_owner': l3_const.DEVICE_OWNER_AGENT_GW } self._test_prepare_direct_delete_dvr_internal_ports(port) @@ -175,6 +176,7 @@ class L3DvrTestCase(testlib_api.SqlTestCase): def test_prevent_delete_csnat_port(self): port = { 'id': 'my_port_id', + 'fixed_ips': mock.ANY, 'device_owner': l3_const.DEVICE_OWNER_ROUTER_SNAT } self._test_prepare_direct_delete_dvr_internal_ports(port)