]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
De-duplicate unit tests for ports in Big Switch
authorKevin Benton <blak111@gmail.com>
Thu, 20 Mar 2014 14:24:33 +0000 (07:24 -0700)
committerMark McClain <mmcclain@yahoo-inc.com>
Fri, 4 Apr 2014 23:15:33 +0000 (19:15 -0400)
This eliminates the separate classes that existed
for the VIF type testing. Each class was going
through all of the port tests when none of the
logic those tests were exercising was affected by
the VIF types.

This cut the number of tests run in test_restproxy_plugin
by close to 44% without a reduction in code coverage.

Closes-Bug: #1295448
Change-Id: I8c84e1599568fad36b6dd3d51e4ba8a3c012c6c5
(cherry picked from commit 913f45bc16dd2c35f7be772d5867f9208064498a)

neutron/tests/unit/bigswitch/test_restproxy_plugin.py

index 061ae8960b80f520202b72221f5ca90ad66fe525..c33be561d84cf709ee19490c72c17d094eab253b 100644 (file)
@@ -181,48 +181,14 @@ class TestBigSwitchProxyPortsV2(test_plugin.TestPortsV2,
         mock_send_all.assert_has_calls([call])
         self.spawn_p.start()
 
-
-class TestBigSwitchProxyPortsV2IVS(test_plugin.TestPortsV2,
-                                   BigSwitchProxyPluginV2TestCase,
-                                   test_bindings.PortBindingsTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_IVS
-    HAS_PORT_FILTER = False
-
-    def setUp(self):
-        super(TestBigSwitchProxyPortsV2IVS,
-              self).setUp()
-        cfg.CONF.set_override('vif_type', 'ivs', 'NOVA')
-
-
-class TestNoHostIDVIFOverride(test_plugin.TestPortsV2,
-                              BigSwitchProxyPluginV2TestCase,
-                              test_bindings.PortBindingsTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_OVS
-    HAS_PORT_FILTER = False
-
-    def setUp(self):
-        super(TestNoHostIDVIFOverride, self).setUp()
-        cfg.CONF.set_override('vif_type', 'ovs', 'NOVA')
-
-    def test_port_vif_details(self):
+    def test_port_vif_details_default(self):
         kwargs = {'name': 'name', 'device_id': 'override_dev'}
         with self.port(**kwargs) as port:
             self.assertEqual(port['port']['binding:vif_type'],
                              portbindings.VIF_TYPE_OVS)
 
-
-class TestBigSwitchVIFOverride(test_plugin.TestPortsV2,
-                               BigSwitchProxyPluginV2TestCase,
-                               test_bindings.PortBindingsTestCase):
-    VIF_TYPE = portbindings.VIF_TYPE_OVS
-    HAS_PORT_FILTER = False
-
-    def setUp(self):
-        super(TestBigSwitchVIFOverride,
-              self).setUp()
-        cfg.CONF.set_override('vif_type', 'ovs', 'NOVA')
-
-    def test_port_vif_details(self):
+    def test_port_vif_details_override(self):
+        # ivshost is in the test config to override to IVS
         kwargs = {'name': 'name', 'binding:host_id': 'ivshost',
                   'device_id': 'override_dev'}
         with self.port(**kwargs) as port:
@@ -234,6 +200,7 @@ class TestBigSwitchVIFOverride(test_plugin.TestPortsV2,
             self.assertEqual(port['port']['binding:vif_type'], self.VIF_TYPE)
 
     def test_port_move(self):
+        # ivshost is in the test config to override to IVS
         kwargs = {'name': 'name', 'binding:host_id': 'ivshost',
                   'device_id': 'override_dev'}
         with self.port(**kwargs) as port:
@@ -256,6 +223,17 @@ class TestBigSwitchVIFOverride(test_plugin.TestPortsV2,
         return self.deserialize(fmt, res)
 
 
+class TestVifDifferentDefault(BigSwitchProxyPluginV2TestCase):
+
+    def setup_config_files(self):
+        super(TestVifDifferentDefault, self).setup_config_files()
+        cfg.CONF.set_override('vif_type', 'ivs', 'NOVA')
+
+    def test_default_viftype(self):
+        with self.port() as port:
+            self.assertEqual(port['port']['binding:vif_type'], 'ivs')
+
+
 class TestBigSwitchProxyNetworksV2(test_plugin.TestNetworksV2,
                                    BigSwitchProxyPluginV2TestCase):