From: Jacek Swiderski Date: Thu, 11 Sep 2014 13:32:18 +0000 (+0200) Subject: Remove faulty .assert_has_calls([]) X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3b0ac61dea7178e858c6dede44a13818c5162283;p=openstack-build%2Fneutron-build.git Remove faulty .assert_has_calls([]) Some UT use .assert_has_calls([]) as a way to check if mock wasn't called - this doesn't work because assert_has_calls only checks if passed calls are present in mock_calls and hence it is always true regardless of whether mock was called or not. This can lead to falsely passed tests. Change-Id: I1be5327854cc3dc2f5b3733f2bad78200cfbbfd2 Closes-Bug: #1368234 --- diff --git a/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py b/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py index ae59764d6..048ddde3b 100644 --- a/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py +++ b/neutron/tests/unit/services/loadbalancer/drivers/radware/test_plugin_driver.py @@ -174,7 +174,7 @@ class TestLoadBalancerPlugin(TestLoadBalancerPluginBase): 'tenant_id', 'port_name', 'network_id', '10.10.10.10') self.plugin_instance._core_plugin.get_ports.assert_called_once() - self.plugin_instance._core_plugin.create_port.assert_has_calls([]) + self.assertFalse(self.plugin_instance._core_plugin.create_port.called) def test_rest_client_recover_was_called(self): """Call the real REST client and verify _recover is called.""" diff --git a/neutron/tests/unit/test_iptables_firewall.py b/neutron/tests/unit/test_iptables_firewall.py index d1da6b275..57b7cd6f5 100644 --- a/neutron/tests/unit/test_iptables_firewall.py +++ b/neutron/tests/unit/test_iptables_firewall.py @@ -1019,7 +1019,7 @@ class IptablesFirewallTestCase(base.BaseTestCase): port = self._fake_port() self.firewall.remove_port_filter(port) # checking no exception occures - self.v4filter_inst.assert_has_calls([]) + self.assertFalse(self.v4filter_inst.called) def test_defer_apply(self): with self.firewall.defer_apply(): diff --git a/neutron/tests/unit/test_linux_interface.py b/neutron/tests/unit/test_linux_interface.py index 809216e6a..a236dd899 100644 --- a/neutron/tests/unit/test_linux_interface.py +++ b/neutron/tests/unit/test_linux_interface.py @@ -394,7 +394,7 @@ class TestBridgeInterfaceDriver(TestBase): 'port-1234', 'tap0', 'aa:bb:cc:dd:ee:ff') - self.ip_dev.assert_has_calls([]) + self.assertFalse(self.ip_dev.called) self.assertEqual(log.call_count, 1) def test_plug_mtu(self): diff --git a/neutron/tests/unit/test_security_groups_rpc.py b/neutron/tests/unit/test_security_groups_rpc.py index d26c904be..524932c9f 100644 --- a/neutron/tests/unit/test_security_groups_rpc.py +++ b/neutron/tests/unit/test_security_groups_rpc.py @@ -1000,7 +1000,7 @@ class SecurityGroupAgentRpcTestCase(BaseSecurityGroupAgentRpcTestCase): self.agent.refresh_firewall = mock.Mock() self.agent.prepare_devices_filter(['fake_port_id']) self.agent.security_groups_rule_updated(['fake_sgid3', 'fake_sgid4']) - self.agent.refresh_firewall.assert_has_calls([]) + self.assertFalse(self.agent.refresh_firewall.called) def test_security_groups_member_updated(self): self.agent.refresh_firewall = mock.Mock() @@ -1013,7 +1013,7 @@ class SecurityGroupAgentRpcTestCase(BaseSecurityGroupAgentRpcTestCase): self.agent.refresh_firewall = mock.Mock() self.agent.prepare_devices_filter(['fake_port_id']) self.agent.security_groups_member_updated(['fake_sgid3', 'fake_sgid4']) - self.agent.refresh_firewall.assert_has_calls([]) + self.assertFalse(self.agent.refresh_firewall.called) def test_security_groups_provider_updated(self): self.agent.refresh_firewall = mock.Mock() @@ -1041,7 +1041,7 @@ class SecurityGroupAgentRpcTestCase(BaseSecurityGroupAgentRpcTestCase): def test_refresh_firewall_none(self): self.agent.refresh_firewall([]) - self.firewall.assert_has_calls([]) + self.assertFalse(self.firewall.called) class SecurityGroupAgentEnhancedRpcTestCase( @@ -1157,7 +1157,7 @@ class SecurityGroupAgentEnhancedRpcTestCase( def test_refresh_firewall_none_enhanced_rpc(self): self.agent.refresh_firewall([]) - self.firewall.assert_has_calls([]) + self.assertFalse(self.firewall.called) class SecurityGroupAgentRpcWithDeferredRefreshTestCase(