]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix test tautology for DVR
authorarmando-migliaccio <armamig@gmail.com>
Thu, 5 Mar 2015 16:37:24 +0000 (08:37 -0800)
committerarmando-migliaccio <armamig@gmail.com>
Thu, 5 Mar 2015 16:37:24 +0000 (08:37 -0800)
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

index 103e100cfa4d13d45135940f93c65367e358224a..2b7fab9355375b32abc20f05feee9ccbf71c8329 100644 (file)
@@ -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)