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
This commit is contained in:
Valeriy Ponomaryov 2015-07-10 12:27:16 +03:00
parent d223645327
commit 6abb30299b
7 changed files with 13 additions and 11 deletions

View File

@ -82,5 +82,5 @@ class ManilaCmdAllTestCase(test.TestCase):
manila_all.main() manila_all.main()
self._common_checks() 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)]) service.serve.assert_has_calls([mock.call(self.wsgi_service)])

View File

@ -264,7 +264,7 @@ class StandaloneNetworkPluginTest(test.TestCase):
fake_context, fake_share_server, fake_share_network, count=0) fake_context, fake_share_server, fake_share_network, count=0)
self.assertEqual([], allocations) 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'], fake_context, fake_share_network['id'],
dict(segmentation_id=None, cidr=instance.net.cidr, ip_version=4)) dict(segmentation_id=None, cidr=instance.net.cidr, ip_version=4))

View File

@ -740,7 +740,8 @@ class HP3ParMediatorTestCase(test.TestCase):
reclaimStrategy='maxspeed'), reclaimStrategy='maxspeed'),
] ]
self.mock_client.assert_has_calls(expected_calls) 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): def test_mediator_get_capacity(self):
"""Mediator converts client stats to capacity result.""" """Mediator converts client stats to capacity result."""

View File

@ -118,7 +118,7 @@ class GPFSShareDriverTestCase(test.TestCase):
def test_do_setup(self): def test_do_setup(self):
self.mock_object(self._driver, '_setup_helpers') self.mock_object(self._driver, '_setup_helpers')
self._driver.do_setup(self._context) 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): def test_setup_helpers(self):
self._driver._helpers = {} self._driver._helpers = {}
@ -480,7 +480,7 @@ class GPFSShareDriverTestCase(test.TestCase):
access_type, access) access_type, access)
self._knfs_helper._execute.assert_called_once_with('exportfs', self._knfs_helper._execute.assert_called_once_with('exportfs',
run_as_root=True) 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) self._knfs_helper._get_export_options.assert_any_call(self.share)
cmd = ['exportfs', '-o', export_opts, ':'.join([access, local_path])] cmd = ['exportfs', '-o', export_opts, ':'.join([access, local_path])]
self._knfs_helper._publish_access.assert_called_once_with(*cmd) self._knfs_helper._publish_access.assert_called_once_with(*cmd)

View File

@ -188,7 +188,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
self._driver._fetch_gluster_volumes.assert_called_once_with() self._driver._fetch_gluster_volumes.assert_called_once_with()
self.assertEqual(expected_exec, fake_utils.fake_execute_get_log()) 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): def test_do_setup_unsupported_glusterfs_version(self):
self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1} self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1}
@ -197,7 +197,7 @@ class GlusterfsNativeShareDriverTestCase(test.TestCase):
self.assertRaises(exception.GlusterfsException, self.assertRaises(exception.GlusterfsException,
self._driver.do_setup, self._context) 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) @ddt.data(exception.GlusterfsException, RuntimeError)
def test_do_setup_get_gluster_version_fails(self, exc): 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', self.mock_object(self.gmgr1, 'get_gluster_version',
mock.Mock(side_effect=raise_exception)) mock.Mock(side_effect=raise_exception))
self.assertRaises(exc, self._driver.do_setup, self._context) 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): def test_do_setup_glusterfs_no_volumes_provided_by_backend(self):
self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1} self._driver.glusterfs_servers = {self.glusterfs_server1: self.gmgr1}

View File

@ -1450,7 +1450,8 @@ class NeutronNetworkHelperTestCase(test.TestCase):
self.assertFalse( self.assertFalse(
service_instance.neutron.API.router_remove_interface.called) 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([]) service_instance.LOG.debug.assert_has_calls([])
def test_teardown_network_with_wrong_ports(self): def test_teardown_network_with_wrong_ports(self):

View File

@ -1411,8 +1411,8 @@ class ShareManagerTestCase(test.TestCase):
mock.call(self.context, share_server['share_network_id'])]) mock.call(self.context, share_server['share_network_id'])])
self.share_manager.driver.allocate_network.assert_has_calls([ self.share_manager.driver.allocate_network.assert_has_calls([
mock.call(self.context, share_server, share_network)]) mock.call(self.context, share_server, share_network)])
self.share_manager.driver.deallocate_network.assert_has_calls( self.share_manager.driver.deallocate_network.assert_has_calls([
mock.call(self.context, share_server['id'])) mock.call(self.context, share_server['id'])])
def test_setup_server_incorrect_detail_data(self): def test_setup_server_incorrect_detail_data(self):
self.setup_server_raise_exception(detail_data_proper=False) self.setup_server_raise_exception(detail_data_proper=False)