From 6abb30299b69a2d07af07a20c554210663edfd14 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Fri, 10 Jul 2015 12:27:16 +0300 Subject: [PATCH] Fix unit tests for compatibility with new mock==1.1.0 After release of mock==1.1.0 lib some our tests became incompatible. Newest 'mock' lib does not have silent errors anymore and now our such errors are discovered. So, fix them. Change-Id: Ibb0e03f3b86e25201b7a888560ff133ebc627722 Closes-Bug: #1473350 --- manila/tests/cmd/test_all.py | 2 +- manila/tests/network/test_standalone_network_plugin.py | 2 +- manila/tests/share/drivers/hp/test_hp_3par_mediator.py | 3 ++- manila/tests/share/drivers/ibm/test_gpfs.py | 4 ++-- manila/tests/share/drivers/test_glusterfs_native.py | 6 +++--- manila/tests/share/drivers/test_service_instance.py | 3 ++- manila/tests/share/test_manager.py | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/manila/tests/cmd/test_all.py b/manila/tests/cmd/test_all.py index 9f130c6f..016f7593 100644 --- a/manila/tests/cmd/test_all.py +++ b/manila/tests/cmd/test_all.py @@ -82,5 +82,5 @@ class ManilaCmdAllTestCase(test.TestCase): manila_all.main() self._common_checks() - self.fake_log.exception.assert_has_calls(mock.ANY) + self.fake_log.exception.assert_has_calls([mock.ANY]) service.serve.assert_has_calls([mock.call(self.wsgi_service)]) diff --git a/manila/tests/network/test_standalone_network_plugin.py b/manila/tests/network/test_standalone_network_plugin.py index e6534049..903c0d3f 100644 --- a/manila/tests/network/test_standalone_network_plugin.py +++ b/manila/tests/network/test_standalone_network_plugin.py @@ -264,7 +264,7 @@ class StandaloneNetworkPluginTest(test.TestCase): fake_context, fake_share_server, fake_share_network, count=0) self.assertEqual([], allocations) - instance.db.share_network_update.assert_called_once_wth( + instance.db.share_network_update.assert_called_once_with( fake_context, fake_share_network['id'], dict(segmentation_id=None, cidr=instance.net.cidr, ip_version=4)) diff --git a/manila/tests/share/drivers/hp/test_hp_3par_mediator.py b/manila/tests/share/drivers/hp/test_hp_3par_mediator.py index 8b9d47af..9ef90754 100644 --- a/manila/tests/share/drivers/hp/test_hp_3par_mediator.py +++ b/manila/tests/share/drivers/hp/test_hp_3par_mediator.py @@ -740,7 +740,8 @@ class HP3ParMediatorTestCase(test.TestCase): reclaimStrategy='maxspeed'), ] self.mock_client.assert_has_calls(expected_calls) - mock_log.assert_has_calls(mock.call.exception(mock.ANY)) + self.assertTrue(mock_log.debug.called) + self.assertTrue(mock_log.exception.called) def test_mediator_get_capacity(self): """Mediator converts client stats to capacity result.""" diff --git a/manila/tests/share/drivers/ibm/test_gpfs.py b/manila/tests/share/drivers/ibm/test_gpfs.py index 654088e0..2f9aaf28 100644 --- a/manila/tests/share/drivers/ibm/test_gpfs.py +++ b/manila/tests/share/drivers/ibm/test_gpfs.py @@ -118,7 +118,7 @@ class GPFSShareDriverTestCase(test.TestCase): def test_do_setup(self): self.mock_object(self._driver, '_setup_helpers') self._driver.do_setup(self._context) - self._driver._setup_helpers.assert_called_any() + self._driver._setup_helpers.assert_called_once_with() def test_setup_helpers(self): self._driver._helpers = {} @@ -480,7 +480,7 @@ class GPFSShareDriverTestCase(test.TestCase): access_type, access) self._knfs_helper._execute.assert_called_once_with('exportfs', run_as_root=True) - re.search.assert_called_any() + self.assertTrue(re.search.called) self._knfs_helper._get_export_options.assert_any_call(self.share) cmd = ['exportfs', '-o', export_opts, ':'.join([access, local_path])] self._knfs_helper._publish_access.assert_called_once_with(*cmd) diff --git a/manila/tests/share/drivers/test_glusterfs_native.py b/manila/tests/share/drivers/test_glusterfs_native.py index 9f62e999..699460be 100644 --- a/manila/tests/share/drivers/test_glusterfs_native.py +++ b/manila/tests/share/drivers/test_glusterfs_native.py @@ -188,7 +188,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase): self._driver._fetch_gluster_volumes.assert_called_once_with() self.assertEqual(expected_exec, fake_utils.fake_execute_get_log()) - self.gmgr1.get_gluster_version.assert_once_called_with() + self.gmgr1.get_gluster_version.assert_called_once_with() def test_do_setup_unsupported_glusterfs_version(self): self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1} @@ -197,7 +197,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase): self.assertRaises(exception.GlusterfsException, self._driver.do_setup, self._context) - self.gmgr1.get_gluster_version.assert_once_called_with() + self.gmgr1.get_gluster_version.assert_called_once_with() @ddt.data(exception.GlusterfsException, RuntimeError) def test_do_setup_get_gluster_version_fails(self, exc): @@ -208,7 +208,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase): self.mock_object(self.gmgr1, 'get_gluster_version', mock.Mock(side_effect=raise_exception)) self.assertRaises(exc, self._driver.do_setup, self._context) - self.gmgr1.get_gluster_version.assert_once_called_with() + self.gmgr1.get_gluster_version.assert_called_once_with() def test_do_setup_glusterfs_no_volumes_provided_by_backend(self): self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1} diff --git a/manila/tests/share/drivers/test_service_instance.py b/manila/tests/share/drivers/test_service_instance.py index aeeaa7e1..3c3bc985 100644 --- a/manila/tests/share/drivers/test_service_instance.py +++ b/manila/tests/share/drivers/test_service_instance.py @@ -1450,7 +1450,8 @@ class NeutronNetworkHelperTestCase(test.TestCase): self.assertFalse( service_instance.neutron.API.router_remove_interface.called) - service_instance.neutron.API.delete_port.assert_called_once(mock.ANY) + service_instance.neutron.API.delete_port.assert_called_once_with( + mock.ANY) service_instance.LOG.debug.assert_has_calls([]) def test_teardown_network_with_wrong_ports(self): diff --git a/manila/tests/share/test_manager.py b/manila/tests/share/test_manager.py index e64e7f38..1c1043a3 100644 --- a/manila/tests/share/test_manager.py +++ b/manila/tests/share/test_manager.py @@ -1411,8 +1411,8 @@ class ShareManagerTestCase(test.TestCase): mock.call(self.context, share_server['share_network_id'])]) self.share_manager.driver.allocate_network.assert_has_calls([ mock.call(self.context, share_server, share_network)]) - self.share_manager.driver.deallocate_network.assert_has_calls( - mock.call(self.context, share_server['id'])) + self.share_manager.driver.deallocate_network.assert_has_calls([ + mock.call(self.context, share_server['id'])]) def test_setup_server_incorrect_detail_data(self): self.setup_server_raise_exception(detail_data_proper=False)