def test_result_asset_download_file(con100, requests_mock, tmp_path): href = API_URL + "/dl/jjr1.tiff" requests_mock.get(href, content=TIFF_CONTENT) job = BatchJob("jj", connection=con100) asset = ResultAsset(job, name="1.tiff", href=href, metadata={'type': 'image/tiff; application=geotiff'}) target = tmp_path / "res.tiff" path = asset.download(target) assert isinstance(path, Path) assert path.name == "res.tiff" with path.open("rb") as f: assert f.read() == TIFF_CONTENT
def test_result_asset_download_folder(con100, requests_mock, tmp_path): href = API_URL + "/dl/jjr1.tiff" requests_mock.get(href, content=TIFF_CONTENT) job = RESTJob("jj", connection=con100) asset = ResultAsset(job, name="1.tiff", href=href, metadata={"type": "image/tiff; application=geotiff"}) target = as_path(tmp_path / "folder") target.mkdir() path = asset.download(target) assert isinstance(path, Path) assert path.name == "1.tiff" with path.open("rb") as f: assert f.read() == TIFF_CONTENT