Change OVS tunnel tests to support unittest.mock

The unit tests in test_ovs_tunnel.py were verifying that
port_exists() was calling bool(), which fails when using
unittest.mock.  Since it doesn't really gain anything,
just remove the check for that exact call.

Trivialfix

Change-Id: Id7712330a24f51f0cfee8d7b3916c05d3501ee3f
This commit is contained in:
Brian Haley 2020-03-17 20:30:42 -04:00 committed by Brian Haley
parent 8c7aac4f3c
commit 45643f2679
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 oslo_config import cfg
from oslo_log import log
import six
from neutron.agent.common import ip_lib
from neutron.agent.common import ovs_lib
@ -31,13 +30,6 @@ from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \
import test_vlanmanager
def nonzero(f):
if six.PY3:
return f.__bool__()
else:
return f.__nonzero__()
# Useful global dummy variables.
NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
LS_ID = 420
@ -257,7 +249,7 @@ class TunnelTest(object):
mock.call.create(secure_mode=True),
mock.call.setup_controllers(mock.ANY),
mock.call.port_exists('patch-int'),
nonzero(mock.call.port_exists()),
mock.ANY,
mock.call.add_patch_port('patch-int', 'patch-tun'),
]
self.mock_int_bridge_expected += [
@ -713,7 +705,7 @@ class TunnelTestUseVethInterco(TunnelTest):
mock.call.create(secure_mode=True),
mock.call.setup_controllers(mock.ANY),
mock.call.port_exists('patch-int'),
nonzero(mock.call.port_exists()),
mock.ANY,
mock.call.add_patch_port('patch-int', 'patch-tun'),
]
self.mock_int_bridge_expected += [
@ -733,7 +725,7 @@ class TunnelTestUseVethInterco(TunnelTest):
self.ipdevice_expected = [
mock.call('int-%s' % self.MAP_TUN_BRIDGE),
mock.call().exists(),
nonzero(mock.call().exists()),
mock.ANY,
mock.call().link.delete()
]
self.ipwrapper_expected = [