From c3b2c2a9a22bac5cf17813c589444d3abebaa23b Mon Sep 17 00:00:00 2001 From: Wojciech Dec Date: Tue, 16 Aug 2016 19:27:01 +0200 Subject: Adding Mitaka networking-old module with the ODL topology based port binding resolution mechanism from https://review.openstack.org/333186 Change-Id: I10d400aac9bb639c146527f0f93e6925cb74d9de Signed-off-by: Wojciech Dec --- .../networking_odl/tests/unit/ml2/test_driver.py | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 networking-odl/networking_odl/tests/unit/ml2/test_driver.py (limited to 'networking-odl/networking_odl/tests/unit/ml2/test_driver.py') diff --git a/networking-odl/networking_odl/tests/unit/ml2/test_driver.py b/networking-odl/networking_odl/tests/unit/ml2/test_driver.py new file mode 100644 index 0000000..661eb55 --- /dev/null +++ b/networking-odl/networking_odl/tests/unit/ml2/test_driver.py @@ -0,0 +1,99 @@ +# Copyright (c) 2013-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. + +import mock +from neutron import context +from neutron.tests.unit.plugins.ml2 import test_plugin + +from networking_odl.common import constants as const +from networking_odl.ml2 import mech_driver as driver + + +class TestODLShim(test_plugin.Ml2PluginV2TestCase): + + def setUp(self): + super(TestODLShim, self).setUp() + self.context = context.get_admin_context() + self.plugin = mock.Mock() + self.driver = driver.OpenDaylightMechanismDriver() + self.driver.odl_drv = mock.Mock() + + def test_create_network_postcommit(self): + self.driver.create_network_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_CREATE, + const.ODL_NETWORKS, + self.context) + + def test_update_network_postcommit(self): + self.driver.update_network_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_UPDATE, + const.ODL_NETWORKS, + self.context) + + def test_delete_network_postcommit(self): + self.driver.delete_network_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_DELETE, + const.ODL_NETWORKS, + self.context) + + def test_create_subnet_postcommit(self): + self.driver.create_subnet_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_CREATE, + const.ODL_SUBNETS, + self.context) + + def test_update_subnet_postcommit(self): + self.driver.update_subnet_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_UPDATE, + const.ODL_SUBNETS, + self.context) + + def test_delete_subnet_postcommit(self): + self.driver.delete_subnet_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_DELETE, + const.ODL_SUBNETS, + self.context) + + def test_create_port_postcommit(self): + self.driver.create_port_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_CREATE, + const.ODL_PORTS, + self.context) + + def test_update_port_postcommit(self): + self.driver.update_port_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_UPDATE, + const.ODL_PORTS, + self.context) + + def test_delete_port_postcommit(self): + self.driver.delete_port_postcommit(self.context) + self.driver.odl_drv.synchronize.assert_called_with(const.ODL_DELETE, + const.ODL_PORTS, + self.context) + + def test_bind_port_delegation(self): + # given front-end with attached back-end + front_end = self.driver + front_end.odl_drv = back_end = mock.MagicMock( + spec=driver.OpenDaylightDriver) + # given PortContext to be forwarded to back-end without using + context = object() + + # when binding port + front_end.bind_port(context) + + # then port is bound by back-end + back_end.bind_port.assert_called_once_with(context) -- cgit 1.2.3-korg