1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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('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('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('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('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('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('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('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('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('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)
|