From: Javeme Date: Thu, 11 Feb 2016 12:09:41 +0000 (+0800) Subject: Don't use Mock.called_once_with that does not exist X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=22cb2e81a6d5dfad022fae5fca7601e2ae9aab88;p=openstack-build%2Fcinder-build.git Don't use Mock.called_once_with that does not exist class mock.Mock does not exist method called_once_with, it just exists method assert_called_once_with. Currently there are still ome places where we use called_once_with method, this patch let's correct it. NOTE: called_once_with() does nothing because it's a mock object. Closes-Bug: #1544522 Change-Id: Iac7c029a1cc66439f43d441bc6d0832686536961 --- diff --git a/cinder/tests/unit/api/contrib/test_volume_unmanage.py b/cinder/tests/unit/api/contrib/test_volume_unmanage.py index 54c9d6dda..eb4ec9846 100644 --- a/cinder/tests/unit/api/contrib/test_volume_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_volume_unmanage.py @@ -65,7 +65,7 @@ class VolumeUnmanageTest(test.TestCase): res = self._get_resp(vol.id) self.assertEqual(202, res.status_int, res) - mock_rpcapi.called_once_with(self.ctxt, mock.ANY, unmanage_only=True) + mock_rpcapi.assert_called_once_with(self.ctxt, mock.ANY, True) vol = objects.volume.Volume.get_by_id(self.ctxt, vol.id) self.assertEqual('deleting', vol.status) db.volume_destroy(self.ctxt, vol.id) diff --git a/cinder/tests/unit/backup/drivers/test_backup_posix.py b/cinder/tests/unit/backup/drivers/test_backup_posix.py index 2f3431d73..2a0f54c9c 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_posix.py +++ b/cinder/tests/unit/backup/drivers/test_backup_posix.py @@ -124,7 +124,7 @@ class PosixBackupDriverTestCase(test.TestCase): self.assertRaises(OSError, self.driver.put_container, FAKE_CONTAINER) os.path.exists.assert_called_once_with(path) - os.makedirs.called_once_with(path) + os.makedirs.assert_called_once_with(path) self.assertEqual(0, os.chmod.call_count) def test_get_container_entries(self): diff --git a/cinder/tests/unit/test_dellfc.py b/cinder/tests/unit/test_dellfc.py index 4a340f8d2..580d3e5da 100644 --- a/cinder/tests/unit/test_dellfc.py +++ b/cinder/tests/unit/test_dellfc.py @@ -621,7 +621,7 @@ class DellSCSanFCDriverTestCase(test.TestCase): mock_init): stats = self.driver.get_volume_stats(True) self.assertEqual('FC', stats['storage_protocol']) - mock_get_storage_usage.called_once_with(64702) + mock_get_storage_usage.assert_called_once_with() @mock.patch.object(dell_storagecenter_api.StorageCenterApi, 'find_sc',