]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Don't use Mock.called_once_with that does not exist
authorJaveme <zhangmei.li@easystack.cn>
Thu, 11 Feb 2016 12:09:41 +0000 (20:09 +0800)
committerJaveme <zhangmei.li@easystack.cn>
Fri, 12 Feb 2016 05:25:31 +0000 (13:25 +0800)
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

cinder/tests/unit/api/contrib/test_volume_unmanage.py
cinder/tests/unit/backup/drivers/test_backup_posix.py
cinder/tests/unit/test_dellfc.py

index 54c9d6dda2b4da56bf30f95b736a05a94f6642c5..eb4ec9846b70dc5d31080e6695d14d9a4cbf4342 100644 (file)
@@ -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)
index 2f3431d7370735913e998ff312826d28ef717781..2a0f54c9ce44a247630728f8e8a5de4c75bd8e73 100644 (file)
@@ -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):
index 4a340f8d27a82b4c2949abdbfc46a9092648dcd0..580d3e5dac3211a18aa4f5d199b358f37871fdf9 100644 (file)
@@ -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',