Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/glance/tests/unit/async_/flows/test_web_download.py b/glance/tests/unit/async_/flows/test_web_download.py
- index cccbf5fca..eec809fe1 100644
- --- a/glance/tests/unit/async_/flows/test_web_download.py
- +++ b/glance/tests/unit/async_/flows/test_web_download.py
- @@ -178,12 +178,29 @@ class TestWebDownloadTask(test_utils.BaseTestCase):
- self.assertEqual(1, mock_unlik.call_count)
- @mock.patch("glance.async_.flows._internal_plugins.web_download.store_api")
- - def test_web_download_revert_without_failure(self, mock_store_api):
- + @mock.patch("glance.common.scripts.utils.get_image_data_iter")
- + def test_web_download_revert_without_failure(self, mock_data,
- + mock_store_api):
- web_download_task = web_download._WebDownload(
- self.task.task_id, self.task_type, self.task_repo,
- self.image_id, self.uri)
- - web_download_task._path = "/path/to_downloaded_data"
- - web_download_task.revert("/path/to_downloaded_data")
- +
- + with mock.patch.object(web_download_task, 'store') as mock_store:
- + # Data iterator reports content-length header of 456
- + mock_data.return_value.headers = {'content-length': 456}
- +
- + # Store returns only 123 bytes read
- + mock_store.add.return_value = "/path/to_downloaded_data", 123
- +
- + # task.execute() should fail because of the mismatch
- + self.assertRaises(glance.common.exception.ImportTaskError,
- + web_download_task.execute)
- +
- + # Call task.revert() like taskflow will
- + web_download_task.revert(None)
- +
- + # Make sure we delete from store with the path that the store
- + # add call returned
- mock_store_api.delete_from_backend.assert_called_once_with(
- "/path/to_downloaded_data")
Advertisement
Add Comment
Please, Sign In to add comment