From 0926eb030a3ff2b1b59ccbab32709a801d5870d1 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 22 Oct 2015 13:48:20 +0900 Subject: [PATCH] Move test_extend_port_dict_no_port_security to where it belongs to extensions/test_portsecurity doesn't seem like an appropriate place for tests which examine details of ML2 extension driver. Change-Id: I56c38a334cba45e204184e5d7d9284dacc29a2e1 --- .../unit/extensions/test_portsecurity.py | 13 -------- .../ml2/extensions/test_port_security.py | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 neutron/tests/unit/plugins/ml2/extensions/test_port_security.py diff --git a/neutron/tests/unit/extensions/test_portsecurity.py b/neutron/tests/unit/extensions/test_portsecurity.py index 353477b6c..c307d771e 100644 --- a/neutron/tests/unit/extensions/test_portsecurity.py +++ b/neutron/tests/unit/extensions/test_portsecurity.py @@ -23,7 +23,6 @@ from neutron.db import securitygroups_db from neutron.extensions import portsecurity as psec from neutron.extensions import securitygroup as ext_sg from neutron import manager -from neutron.plugins.ml2.extensions import port_security from neutron.tests.unit.db import test_db_base_plugin_v2 from neutron.tests.unit.extensions import test_securitygroup @@ -400,15 +399,3 @@ class TestPortSecurity(PortSecurityDBTestCase): '', 'not_network_owner') res = req.get_response(self.api) self.assertEqual(res.status_int, exc.HTTPForbidden.code) - - def test_extend_port_dict_no_port_security(self): - """Test _extend_port_security_dict won't crash - if port_security item is None - """ - for db_data in ({'port_security': None, 'name': 'net1'}, {}): - response_data = {} - - driver = port_security.PortSecurityExtensionDriver() - driver._extend_port_security_dict(response_data, db_data) - - self.assertTrue(response_data[psec.PORTSECURITY]) diff --git a/neutron/tests/unit/plugins/ml2/extensions/test_port_security.py b/neutron/tests/unit/plugins/ml2/extensions/test_port_security.py new file mode 100644 index 000000000..06ebd5baa --- /dev/null +++ b/neutron/tests/unit/plugins/ml2/extensions/test_port_security.py @@ -0,0 +1,32 @@ +# Copyright (c) 2015 OpenStack Foundation. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron.extensions import portsecurity as psec +from neutron.plugins.ml2.extensions import port_security +from neutron.tests.unit.plugins.ml2 import test_plugin + + +class TestML2ExtensionPortSecurity(test_plugin.Ml2PluginV2TestCase): + def test_extend_port_dict_no_port_security(self): + """Test _extend_port_security_dict won't crash + if port_security item is None + """ + for db_data in ({'port_security': None, 'name': 'net1'}, {}): + response_data = {} + + driver = port_security.PortSecurityExtensionDriver() + driver._extend_port_security_dict(response_data, db_data) + + self.assertTrue(response_data[psec.PORTSECURITY]) -- 2.45.2