Make test_security_groups work with CONF.use_neutron=True by default

The tests in this module are all based on using nova-network for
security groups so we need to explicitly set use_neutron=False for
these tests. The security groups REST API is tested using Neutron
in the test_neutron_security_groups module.

Because of the joy of multiple inheritance we do have to modify
the test_neutron_security_groups tests to set an attribute that is
used in the base test classes before creating the controller object.

Part of blueprint use-neutron-by-default

Change-Id: I814949630bcef296773c14bff21b921d58c25d8b
This commit is contained in:
Matt Riedemann 2016-12-29 14:21:38 -05:00
parent 531d54e32c
commit a507856bde
2 changed files with 16 additions and 3 deletions

View File

@ -55,6 +55,8 @@ class TestNeutronSecurityGroupsTestCase(test.TestCase):
class TestNeutronSecurityGroupsV21(
test_security_groups.TestSecurityGroupsV21,
TestNeutronSecurityGroupsTestCase):
# Used to override set config in the base test in test_security_groups.
use_neutron = True
def _create_sg_template(self, **kwargs):
sg = test_security_groups.security_group_request_template(**kwargs)
@ -479,7 +481,8 @@ class TestNeutronSecurityGroupRulesV21(
_TestNeutronSecurityGroupRulesBase,
test_security_groups.TestSecurityGroupRulesV21,
TestNeutronSecurityGroupRulesTestCase):
pass
# Used to override set config in the base test in test_security_groups.
use_neutron = True
class TestNeutronSecurityGroupsOutputTest(TestNeutronSecurityGroupsTestCase):

View File

@ -132,10 +132,14 @@ class TestSecurityGroupsV21(test.TestCase):
secgrp_ctl_cls = secgroups_v21.SecurityGroupController
server_secgrp_ctl_cls = secgroups_v21.ServerSecurityGroupController
secgrp_act_ctl_cls = secgroups_v21.SecurityGroupActionController
# This class is subclassed by Neutron security group API tests so we need
# to be able to override this before creating the controller object.
use_neutron = False
def setUp(self):
super(TestSecurityGroupsV21, self).setUp()
# Neutron security groups are tested in test_neutron_security_groups.py
self.flags(use_neutron=self.use_neutron)
self.controller = self.secgrp_ctl_cls()
self.server_controller = self.server_secgrp_ctl_cls()
self.manager = self.secgrp_act_ctl_cls()
@ -782,10 +786,14 @@ class TestSecurityGroupsV21(test.TestCase):
class TestSecurityGroupRulesV21(test.TestCase):
secgrp_ctl_cls = secgroups_v21.SecurityGroupRulesController
# This class is subclassed by Neutron security group API tests so we need
# to be able to override this before creating the controller object.
use_neutron = False
def setUp(self):
super(TestSecurityGroupRulesV21, self).setUp()
# Neutron security groups are tested in test_neutron_security_groups.py
self.flags(use_neutron=self.use_neutron)
self.controller = self.secgrp_ctl_cls()
if self.controller.security_group_api.id_is_uuid:
id1 = '11111111-1111-1111-1111-111111111111'
@ -1309,6 +1317,8 @@ class SecurityGroupsOutputTestV21(test.TestCase):
def setUp(self):
super(SecurityGroupsOutputTestV21, self).setUp()
# Neutron security groups are tested in test_neutron_security_groups.py
self.flags(use_neutron=False)
fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)