|
9 | 9 |
|
10 | 10 | import openeo |
11 | 11 | import openeo.rest.job |
12 | | -from openeo.rest import JobFailedException, OpenEoClientException |
| 12 | +from openeo.rest import JobFailedException, OpenEoApiPlainError, OpenEoClientException |
13 | 13 | from openeo.rest.job import BatchJob, ResultAsset |
14 | 14 |
|
15 | 15 | from .test_connection import _credentials_basic_handler |
@@ -608,20 +608,16 @@ def test_result_asset_download_file(con100, requests_mock, tmp_path): |
608 | 608 |
|
609 | 609 | def test_result_asset_download_file_error(con100, requests_mock, tmp_path): |
610 | 610 | 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!") |
613 | 612 |
|
614 | 613 | 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()) == [] |
625 | 621 |
|
626 | 622 |
|
627 | 623 | def test_result_asset_download_folder(con100, requests_mock, tmp_path): |
|
0 commit comments