Skip to content

Commit 112ed75

Browse files
committed
Finetune test_result_asset_download_file_error
1 parent f40b498 commit 112ed75

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tests/rest/test_job.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import openeo
1111
import openeo.rest.job
12-
from openeo.rest import JobFailedException, OpenEoClientException
12+
from openeo.rest import JobFailedException, OpenEoApiPlainError, OpenEoClientException
1313
from openeo.rest.job import BatchJob, ResultAsset
1414

1515
from .test_connection import _credentials_basic_handler
@@ -608,20 +608,16 @@ def test_result_asset_download_file(con100, requests_mock, tmp_path):
608608

609609
def test_result_asset_download_file_error(con100, requests_mock, tmp_path):
610610
href = API_URL + "/dl/jjr1.tiff"
611-
requests_mock.get(href, content=TIFF_CONTENT)
612-
href_404 = API_URL + "/dl/non-existing-url.tiff"
611+
requests_mock.get(href, status_code=500, text="Nope!")
613612

614613
job = BatchJob("jj", connection=con100)
615-
asset = ResultAsset(job, name="1.tiff", href=href_404, metadata={"type": "image/tiff; application=geotiff"})
616-
target = tmp_path / "res.tiff"
617-
path = target
618-
# noinspection PyBroadException
619-
try:
620-
path = asset.download(target)
621-
except:
622-
pass
623-
assert not target.exists()
624-
assert not path.exists()
614+
asset = ResultAsset(job, name="1.tiff", href=href, metadata={"type": "image/tiff; application=geotiff"})
615+
616+
with pytest.raises(OpenEoApiPlainError, match="Nope!"):
617+
_ = asset.download(tmp_path / "res.tiff")
618+
619+
# Nothing should be downloaded
620+
assert list(tmp_path.iterdir()) == []
625621

626622

627623
def test_result_asset_download_folder(con100, requests_mock, tmp_path):

0 commit comments

Comments
 (0)