Skip to content

Commit 6e32d83

Browse files
authored
refactor: adapt to change of stream download in eodag (#100)
`_stream_download_dict` has been changed to `stream_download` in eodag
1 parent 8a0223a commit 6e32d83

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

stac_fastapi/eodag/extensions/data_download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def get_data(
198198
logger.info("Presigned url could not be fetched for %s", asset_name)
199199

200200
try:
201-
s = product.downloader._stream_download_dict(
201+
s = product.downloader.stream_download(
202202
product,
203203
auth=auth,
204204
asset=asset_name if asset_name != "downloadLink" else None,

tests/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,19 +511,19 @@ def mock_download(mocker, app):
511511

512512

513513
@pytest.fixture(scope="function")
514-
def mock_base_stream_download_dict(mocker):
514+
def mock_base_stream_download(mocker):
515515
"""
516-
Mocks the `_stream_download_dict` method of the `Download` plugin.
516+
Mocks the `stream_download` method of the `Download` plugin.
517517
"""
518-
return mocker.patch.object(Download, "_stream_download_dict")
518+
return mocker.patch.object(Download, "stream_download")
519519

520520

521521
@pytest.fixture(scope="function")
522-
def mock_http_base_stream_download_dict(mocker):
522+
def mock_http_base_stream_download(mocker):
523523
"""
524-
Mocks the `_stream_download_dict` method of the `Download` plugin.
524+
Mocks the `stream_download` method of the `Download` plugin.
525525
"""
526-
return mocker.patch.object(HTTPDownload, "_stream_download_dict")
526+
return mocker.patch.object(HTTPDownload, "stream_download")
527527

528528

529529
@pytest.fixture(scope="function")

tests/test_download.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131

3232
async def test_download_item_from_collection_stream(
33-
request_valid_raw, defaults, mock_base_stream_download_dict, mock_base_authenticate, stream_response
33+
request_valid_raw, defaults, mock_base_stream_download, mock_base_authenticate, stream_response
3434
):
3535
"""Download through eodag server catalog should return a valid response"""
36-
mock_base_stream_download_dict.return_value = stream_response
36+
mock_base_stream_download.return_value = stream_response
3737

3838
resp = await request_valid_raw(f"data/peps/{defaults.collection}/foo/downloadLink")
3939
assert resp.content == b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -42,14 +42,14 @@ async def test_download_item_from_collection_stream(
4242

4343

4444
async def test_download_item_from_collection_no_stream(
45-
request_valid_raw, defaults, mock_download, mock_base_stream_download_dict, mock_base_authenticate, tmp_dir
45+
request_valid_raw, defaults, mock_download, mock_base_stream_download, mock_base_authenticate, tmp_dir
4646
):
4747
"""Download through eodag server catalog should return a valid response even if streaming is not available"""
4848
# download should be performed locally then deleted if streaming is not available
4949
expected_file = tmp_dir / "foo.tar"
5050
expected_file.touch()
5151
mock_download.return_value = expected_file
52-
mock_base_stream_download_dict.side_effect = NotImplementedError()
52+
mock_base_stream_download.side_effect = NotImplementedError()
5353

5454
await request_valid_raw(f"data/peps/{defaults.collection}/foo/downloadLink")
5555
mock_download.assert_called_once()
@@ -63,7 +63,7 @@ async def test_download_auto_order_whitelist(
6363
mock_order,
6464
mock_search,
6565
defaults,
66-
mock_http_base_stream_download_dict,
66+
mock_http_base_stream_download,
6767
stream_response,
6868
):
6969
"""Test that the order method is called when downloading a product
@@ -98,7 +98,7 @@ async def test_download_auto_order_whitelist(
9898
product.register_downloader(downloader=downloader, authenticator=None)
9999

100100
mock_search.return_value = SearchResult([product])
101-
mock_http_base_stream_download_dict.return_value = stream_response
101+
mock_http_base_stream_download.return_value = stream_response
102102

103103
await request_valid_raw(url, search_result=SearchResult([product]))
104104

0 commit comments

Comments
 (0)