Skip to content

Commit c771dec

Browse files
committed
test: fix tests after refactoring and rebase
1 parent 0e981c2 commit c771dec

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

tests/units/test_http_server.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from fastapi.testclient import TestClient
2929
from shapely.geometry import box
3030

31+
from eodag import EOProduct
3132
from tests import mock
3233
from tests.context import (
3334
DEFAULT_ITEMS_PER_PAGE,
@@ -1000,7 +1001,7 @@ def test_download_item_from_collection_api_plugin(self, mock_download, mock_auth
10001001
), f"File {expected_file} should have been deleted"
10011002

10021003
@mock.patch(
1003-
"eodag.rest.utils.eodag_api._plugins_manager.get_search_plugins",
1004+
"eodag.plugins.search.qssearch.QueryStringSearch.query",
10041005
autospec=True,
10051006
)
10061007
@mock.patch(
@@ -1013,20 +1014,25 @@ def test_download_item_from_collection_api_plugin(self, mock_download, mock_auth
10131014
)
10141015
def test_download_without_search_by_id(self, mock_download, mock_auth, mock_plugin):
10151016
product_id = "a_nice_product"
1016-
download_info = {
1017-
product_id: {
1018-
"downloadLink": "https://bla.bli",
1019-
"orderLink": "https://bla.bli/blu",
1020-
"provider": "onda",
1021-
}
1017+
properties = {
1018+
"id": product_id,
1019+
"downloadLink": "https://bla.bli",
1020+
"orderLink": "https://bla.bli/blu",
1021+
"geometry": "-180 -90 180 90",
1022+
"title": product_id,
10221023
}
1023-
plugin_mock_value = mock.MagicMock(download_info=download_info)
1024-
mock_plugin.return_value = iter([plugin_mock_value])
1024+
product = EOProduct("onda", properties, productType=self.tested_product_type)
1025+
mock_plugin.return_value = [product], 1
1026+
# search products
1027+
self.app.get(
1028+
f"search?collections={self.tested_product_type}&bbox=0,43,1,44&datetime=2018-01-20/2018-01-25",
1029+
follow_redirects=True,
1030+
)
10251031

10261032
mock_download.return_value = {"content": iter([""])}
1027-
# check that download request is working without attempt to execute search
1033+
# check that download of returned product is working without attempt to execute search
10281034
self._request_valid_raw(
1029-
f"collections/some-collection/items/{product_id}/download?provider=onda",
1035+
f"collections/{self.tested_product_type}/items/a_nice_product/download?provider=peps",
10301036
search_call_count=0,
10311037
)
10321038

tests/units/test_search_plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ def test_plugins_search_odatav4search_distinct_product_type_mtd_mapping(
11101110
],
11111111
}
11121112
copy_res = copy.deepcopy(result)
1113-
mock__request.return_value.json.side_effect = [result, copy_res]
1113+
mock__request.return_value.json.side_effect = [3, result, 3, copy_res]
11141114
search_plugin = self.onda_search_plugin
11151115

11161116
# update metadata_mapping only for S1_SAR_GRD

0 commit comments

Comments
 (0)