Skip to content

Commit

Permalink
test: update and fix tests following rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Aug 25, 2023
1 parent 4edd1b5 commit bafaf91
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions tests/units/test_download_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,46 @@ def test_plugins_download_http_ok(self, mock_requests_session_request):
self.assertEqual(path, os.path.join(self.output_dir, "dummy_product"))
self.assertTrue(os.path.isfile(path))

mock_requests_session_request.assert_called_once()
# mock_requests_session_request.assert_called_once()
mock_requests_session_request.assert_called_once_with(
mock.ANY,
"get",
self.product.remote_location,
stream=True,
auth=None,
params=plugin.config.dl_url_params,
headers=USER_AGENT,
timeout=DEFAULT_STREAM_REQUESTS_TIMEOUT,
)

# download a lone file with different extension and results output configuration
mock_requests_session_request.reset_mock()
self.product = EOProduct(
"meteoblue",
dict(
geometry="POINT (0 0)",
title="dummy_product_2",
id="dummy_2",
),
)
plugin = self.get_download_plugin(self.product)
self.product.location = self.product.remote_location = "http://somewhereelse"
self.product.properties["id"] = "someotherproduct"

path = plugin.download(self.product, outputs_prefix=self.output_dir)

self.assertEqual(path, os.path.join(self.output_dir, "dummy_product_2"))
self.assertTrue(os.path.isfile(os.path.join(path, os.listdir(path)[0])))
mock_requests_session_request.assert_called_once_with(
mock.ANY,
"post",
self.product.remote_location,
stream=True,
auth=None,
params={},
headers=USER_AGENT,
timeout=DEFAULT_STREAM_REQUESTS_TIMEOUT,
)

@mock.patch("eodag.plugins.download.http.requests.Session.request", autospec=True)
@mock.patch("eodag.plugins.download.http.requests.head", autospec=True)
Expand Down Expand Up @@ -223,34 +262,6 @@ def test_plugins_download_http_ignore_assets(
)
mock_requests_session.assert_not_called()

# download a lone file with different extension and results output configuration
mock_requests_get.reset_mock()
self.product = EOProduct(
"meteoblue",
dict(
geometry="POINT (0 0)",
title="dummy_product_2",
id="dummy_2",
),
)
plugin = self.get_download_plugin(self.product)
self.product.location = self.product.remote_location = "http://somewhereelse"
self.product.properties["id"] = "someotherproduct"

path = plugin.download(self.product, outputs_prefix=self.output_dir)

self.assertEqual(path, os.path.join(self.output_dir, "dummy_product_2"))
self.assertTrue(os.path.isfile(os.path.join(path, os.listdir(path)[0])))
mock_requests_get.assert_called_once_with(
"post",
self.product.remote_location,
stream=True,
auth=None,
params={},
headers=USER_AGENT,
timeout=DEFAULT_STREAM_REQUESTS_TIMEOUT,
)

@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_filename_from_href(
Expand Down

0 comments on commit bafaf91

Please sign in to comment.