From 521e036a45eeb26c72e66aae2dab1a3b383bccc5 Mon Sep 17 00:00:00 2001 From: Eugene Nikanorov Date: Sat, 25 Apr 2015 00:50:25 +0400 Subject: [PATCH] Move test_get_user_allocation*returns_none test to a proper class Move it out of NeutronDbPluginV2TestCase so there is no test duplication. Change-Id: Ib01f2d651c1b0a48062656bd1f66c52481a86ad6 Closes-Bug: #1448268 --- .../tests/unit/db/test_db_base_plugin_v2.py | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 416247884..a088e3522 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -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): -- 2.45.2