Mock sleep in UT
The test_create_disk_from_image test hits a code path that calls time.sleep. However time.sleep is not mocked in the test. This reduces the test runtime by mocking the sleep call. Change-Id: I8c8ac89f5da955b7ac2459839c11283ff04fa283
This commit is contained in:
parent
37bd8a3e7a
commit
ad1967a70e
|
@ -102,10 +102,12 @@ class TestLocalDisk(test.NoDBTestCase):
|
|||
mock_get_image.reset_mock()
|
||||
exception = Exception
|
||||
mock_get_image.side_effect = exception
|
||||
self.assertRaises(exception,
|
||||
self.get_ls(self.apt).create_disk_from_image,
|
||||
None, inst, powervm.TEST_IMAGE1)
|
||||
with mock.patch('time.sleep', autospec=True) as mock_sleep:
|
||||
self.assertRaises(exception,
|
||||
self.get_ls(self.apt).create_disk_from_image,
|
||||
None, inst, powervm.TEST_IMAGE1)
|
||||
self.assertEqual(mock_get_image.call_count, 4)
|
||||
self.assertEqual(3, mock_sleep.call_count)
|
||||
|
||||
@mock.patch('pypowervm.tasks.storage.upload_new_vdisk', autospec=True)
|
||||
@mock.patch('nova.image.api.API.download')
|
||||
|
|
Loading…
Reference in New Issue