Fix security groups tests

Commit I2586f0b11b107d7f57214a0d65bcf7c38a5f0ebb broke our
unit tests extension handling.

Change-Id: Id7049b4e4db31e2785a7dee73b81c73937dae3f6
This commit is contained in:
Adit Sarfaty 2017-10-26 09:28:28 +03:00
parent 2caa2dd076
commit a56e11d3ac
3 changed files with 10 additions and 9 deletions

View File

@ -19,6 +19,7 @@ from neutron.api.v2 import attributes as attr
from neutron.db import api as db_api
from neutron.db import db_base_plugin_v2
from neutron.db import securitygroups_db
from neutron.extensions import securitygroup as ext_sg
from neutron.tests.unit.extensions import test_securitygroup
from neutron_lib import context
@ -132,7 +133,7 @@ class ProviderSecurityGroupExtTestCase(
plugin=plugin, ext_mgr=ext_mgr)
self._tenant_id = 'foobar'
# add provider group attributes
attr.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
ext_sg.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
provider_sg.EXTENDED_ATTRIBUTES_2_0['security_groups'])
attr.RESOURCE_ATTRIBUTE_MAP['ports'].update(
@ -140,7 +141,7 @@ class ProviderSecurityGroupExtTestCase(
def tearDown(self):
# remove provider security group attributes
del attr.RESOURCE_ATTRIBUTE_MAP['security_groups']['provider']
del ext_sg.RESOURCE_ATTRIBUTE_MAP['security_groups']['provider']
del attr.RESOURCE_ATTRIBUTE_MAP['ports']['provider_security_groups']
super(ProviderSecurityGroupExtTestCase, self).tearDown()

View File

@ -18,10 +18,10 @@ import webob.exc
from oslo_utils import uuidutils
from neutron.api.v2 import attributes
from neutron.db import api as db_api
from neutron.db import db_base_plugin_v2
from neutron.db import securitygroups_db
from neutron.extensions import securitygroup as ext_sg
from neutron.tests.unit.extensions import test_securitygroup
from neutron_lib import constants as const
from neutron_lib.plugins import directory
@ -61,14 +61,14 @@ class LocalIPPrefixExtTestCase(test_securitygroup.SecurityGroupDBTestCase):
def setUp(self, plugin=PLUGIN_NAME, ext_mgr=None):
super(LocalIPPrefixExtTestCase, self).setUp(
plugin=plugin, ext_mgr=ext_mgr)
attributes.RESOURCE_ATTRIBUTE_MAP['security_group_rules'].update(
ext_sg.RESOURCE_ATTRIBUTE_MAP['security_group_rules'].update(
ext_loip.RESOURCE_ATTRIBUTE_MAP['security_group_rules'])
def tearDown(self):
# Remove attributes which were written to global attr map, they may
# interfer with tests for other plugins which doesn't support this
# extension.
del attributes.RESOURCE_ATTRIBUTE_MAP[
del ext_sg.RESOURCE_ATTRIBUTE_MAP[
'security_group_rules']['local_ip_prefix']
super(LocalIPPrefixExtTestCase, self).tearDown()

View File

@ -16,7 +16,7 @@ import mock
from oslo_config import cfg
import webob.exc
from neutron.api.v2 import attributes as attr
from neutron.extensions import securitygroup as ext_sg
from neutron.tests.unit.api import test_extensions
from neutron.tests.unit.extensions import test_securitygroup
from neutron_lib import constants
@ -46,14 +46,14 @@ class SecGroupPolicyExtensionTestCase(
plugin=plugin, ext_mgr=ext_mgr)
self._tenant_id = 'foobar'
# add policy & logging security group attribute
attr.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
ext_sg.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
ext_policy.RESOURCE_ATTRIBUTE_MAP['security_groups'])
attr.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
ext_sg.RESOURCE_ATTRIBUTE_MAP['security_groups'].update(
ext_logging.RESOURCE_ATTRIBUTE_MAP['security_groups'])
def tearDown(self):
# remove policy security group attribute
del attr.RESOURCE_ATTRIBUTE_MAP['security_groups']['policy']
del ext_sg.RESOURCE_ATTRIBUTE_MAP['security_groups']['policy']
super(SecGroupPolicyExtensionTestCase, self).tearDown()
def _create_secgroup_with_policy(self, policy_id, description=None,