Skip to content

Commit

Permalink
test: error in stream download of several assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jlahovnik committed Jan 17, 2025
1 parent 996b14b commit c5f62d8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/units/test_download_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,38 @@ def test_plugins_download_http_assets_interrupt(
)
)

@mock.patch(
"eodag.plugins.download.http.ProgressCallback.__call__",
autospec=True,
)
@mock.patch("eodag.plugins.download.http.requests.head", autospec=True)
@mock.patch("eodag.plugins.download.http.requests.get", autospec=True)
def test_plugins_download_http_assets_stream_zip_interrupt(
self, mock_requests_get, mock_requests_head, mock_progress_callback
):
"""HTTPDownload.download() must download assets to a temporary file"""

plugin = self.get_download_plugin(self.product)
self.product.location = self.product.remote_location = "http://somewhere"
self.product.properties["id"] = "someproduct"
self.product.assets.clear()
self.product.assets.update({"foo": {"href": "http://somewhere/something"}})
self.product.assets.update({"any": {"href": "http://somewhere/anything"}})

# first asset returns error
mock_requests_get.return_value = MockResponse(status_code=404)
mock_requests_head.return_value.headers = {
"content-disposition": "",
"Content-length": "10",
}

with self.assertRaises(DownloadError):
plugin._stream_download_dict(self.product, output_dir=self.output_dir)
# Interrupted download
# Product location not changed
self.assertEqual(self.product.location, "http://somewhere")
self.assertEqual(self.product.remote_location, "http://somewhere")

@mock.patch("eodag.plugins.download.http.requests.head", autospec=True)
@mock.patch("eodag.plugins.download.http.requests.get", autospec=True)
def test_plugins_download_http_assets_resume(
Expand Down

0 comments on commit c5f62d8

Please sign in to comment.