From 45643f26792d314e67cf1f444bf6eae9be8f6dd9 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Tue, 17 Mar 2020 20:30:42 -0400 Subject: [PATCH] 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 --- .../drivers/openvswitch/agent/test_ovs_tunnel.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py index ca14e0f1ae2..527e13190d4 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py @@ -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 = [