def test_download_result_multiple(job_with_2_assets: RESTJob, tmp_path): job = job_with_2_assets expected = re.escape( "Can not use `download_file` with multiple assets. Use `download_files` instead" ) with pytest.raises(OpenEoClientException, match=expected): job.download_result(tmp_path / "res.tiff")
def test_download_result(job_with_1_asset: BatchJob, tmp_path): job = job_with_1_asset target = tmp_path / "result.tiff" res = job.download_result(target) assert res == target with target.open("rb") as f: assert f.read() == TIFF_CONTENT
def test_download_result_folder(job_with_1_asset: BatchJob, tmp_path): job = job_with_1_asset target = tmp_path / "folder" target.mkdir() res = job.download_result(target) assert res == target / "1.tiff" assert list(p.name for p in target.iterdir()) == ["1.tiff"] with (target / "1.tiff").open("rb") as f: assert f.read() == TIFF_CONTENT
def test_download_result_040(session040, requests_mock, tmp_path): requests_mock.get(API_URL + "/jobs/jj/results", json={"links": [ {"href": API_URL + "/dl/jjr1.tiff"}, ]}) requests_mock.get(API_URL + "/dl/jjr1.tiff", content=TIFF_CONTENT) job = BatchJob("jj", connection=session040) assert job.list_results() == {'links': [{'href': 'https://oeo.test/dl/jjr1.tiff'}]} target = tmp_path / "result.tiff" res = job.download_result(target) assert res == target with target.open("rb") as f: assert f.read() == TIFF_CONTENT