]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move test_get_user_allocation*returns_none test to a proper class
authorEugene Nikanorov <enikanorov@mirantis.com>
Fri, 24 Apr 2015 20:50:25 +0000 (00:50 +0400)
committerEugene Nikanorov <enikanorov@mirantis.com>
Fri, 24 Apr 2015 20:50:25 +0000 (00:50 +0400)
Move it out of NeutronDbPluginV2TestCase so there is no test
duplication.

Change-Id: Ib01f2d651c1b0a48062656bd1f66c52481a86ad6
Closes-Bug: #1448268

neutron/tests/unit/db/test_db_base_plugin_v2.py

index 4162478847267d39650ee8ca1d6856edae1bd3a0..a088e3522707341ff288aa67de0d26af28a4238e 100644 (file)
@@ -2722,29 +2722,6 @@ class TestNetworksV2(NeutronDbPluginV2TestCase):
                 res = self.deserialize(self.fmt, req)
                 self.assertEqual(res['network']['admin_state_up'], v[1])
 
-    def test_get_user_allocation_for_dhcp_port_returns_none(self):
-        plugin = manager.NeutronManager.get_plugin()
-        if not hasattr(plugin, '_subnet_get_user_allocation'):
-            return
-        with contextlib.nested(
-            self.network(),
-            self.network()
-        ) as (net, net1):
-            with contextlib.nested(
-                self.subnet(network=net, cidr='10.0.0.0/24'),
-                self.subnet(network=net1, cidr='10.0.1.0/24')
-            ) as (subnet, subnet1):
-                with contextlib.nested(
-                    self.port(subnet=subnet, device_owner='network:dhcp'),
-                    self.port(subnet=subnet1)
-                ) as (p, p2):
-                    # check that user allocations on another network don't
-                    # affect _subnet_get_user_allocation method
-                    res = plugin._subnet_get_user_allocation(
-                        context.get_admin_context(),
-                        subnet['subnet']['id'])
-                    self.assertIsNone(res)
-
 
 class TestSubnetsV2(NeutronDbPluginV2TestCase):
 
@@ -5502,7 +5479,8 @@ class TestNeutronDbPluginV2(base.BaseTestCase):
         self._test__allocate_ips_for_port(subnets, port, expected)
 
 
-class NeutronDbPluginV2AsMixinTestCase(testlib_api.SqlTestCase):
+class NeutronDbPluginV2AsMixinTestCase(NeutronDbPluginV2TestCase,
+                                       testlib_api.SqlTestCase):
     """Tests for NeutronDbPluginV2 as Mixin.
 
     While NeutronDbPluginV2TestCase checks NeutronDbPlugin and all plugins as
@@ -5536,6 +5514,27 @@ class NeutronDbPluginV2AsMixinTestCase(testlib_api.SqlTestCase):
         net = self.plugin.create_network(self.context, self.net_data)
         self.assertEqual(net['status'], 'BUILD')
 
+    def test_get_user_allocation_for_dhcp_port_returns_none(self):
+        plugin = manager.NeutronManager.get_plugin()
+        with contextlib.nested(
+            self.network(),
+            self.network()
+        ) as (net, net1):
+            with contextlib.nested(
+                self.subnet(network=net, cidr='10.0.0.0/24'),
+                self.subnet(network=net1, cidr='10.0.1.0/24')
+            ) as (subnet, subnet1):
+                with contextlib.nested(
+                    self.port(subnet=subnet, device_owner='network:dhcp'),
+                    self.port(subnet=subnet1)
+                ) as (p, p2):
+                    # check that user allocations on another network don't
+                    # affect _subnet_get_user_allocation method
+                    res = plugin._subnet_get_user_allocation(
+                        context.get_admin_context(),
+                        subnet['subnet']['id'])
+                    self.assertIsNone(res)
+
 
 class TestNetworks(testlib_api.SqlTestCase):
     def setUp(self):