Merge "Change OVS tunnel tests to support unittest.mock"

This commit is contained in:
Zuul 2020-03-24 16:20:19 +00:00 committed by Gerrit Code Review
commit 56c7db5e7f
1 changed files with 3 additions and 11 deletions

View File

@ -20,7 +20,6 @@ import mock
from neutron_lib import constants as n_const from neutron_lib import constants as n_const
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
import six
from neutron.agent.common import ip_lib from neutron.agent.common import ip_lib
from neutron.agent.common import ovs_lib from neutron.agent.common import ovs_lib
@ -31,13 +30,6 @@ from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \
import test_vlanmanager import test_vlanmanager
def nonzero(f):
if six.PY3:
return f.__bool__()
else:
return f.__nonzero__()
# Useful global dummy variables. # Useful global dummy variables.
NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7' NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
LS_ID = 420 LS_ID = 420
@ -257,7 +249,7 @@ class TunnelTest(object):
mock.call.create(secure_mode=True), mock.call.create(secure_mode=True),
mock.call.setup_controllers(mock.ANY), mock.call.setup_controllers(mock.ANY),
mock.call.port_exists('patch-int'), mock.call.port_exists('patch-int'),
nonzero(mock.call.port_exists()), mock.ANY,
mock.call.add_patch_port('patch-int', 'patch-tun'), mock.call.add_patch_port('patch-int', 'patch-tun'),
] ]
self.mock_int_bridge_expected += [ self.mock_int_bridge_expected += [
@ -713,7 +705,7 @@ class TunnelTestUseVethInterco(TunnelTest):
mock.call.create(secure_mode=True), mock.call.create(secure_mode=True),
mock.call.setup_controllers(mock.ANY), mock.call.setup_controllers(mock.ANY),
mock.call.port_exists('patch-int'), mock.call.port_exists('patch-int'),
nonzero(mock.call.port_exists()), mock.ANY,
mock.call.add_patch_port('patch-int', 'patch-tun'), mock.call.add_patch_port('patch-int', 'patch-tun'),
] ]
self.mock_int_bridge_expected += [ self.mock_int_bridge_expected += [
@ -733,7 +725,7 @@ class TunnelTestUseVethInterco(TunnelTest):
self.ipdevice_expected = [ self.ipdevice_expected = [
mock.call('int-%s' % self.MAP_TUN_BRIDGE), mock.call('int-%s' % self.MAP_TUN_BRIDGE),
mock.call().exists(), mock.call().exists(),
nonzero(mock.call().exists()), mock.ANY,
mock.call().link.delete() mock.call().link.delete()
] ]
self.ipwrapper_expected = [ self.ipwrapper_expected = [