Exemplo n.º 1
0
def test_download_result_multiple(con100, requests_mock, tmp_path):
    requests_mock.get(API_URL + "/jobs/jj/results", json={"assets": {
        "1.tiff": {"href": API_URL + "/dl/jjr1.tiff"},
        "2.tiff": {"href": API_URL + "/dl/jjr2.tiff"},
    }})
    job = RESTJob("jj", connection=con100)
    with pytest.raises(OpenEoClientException, match="Expected one result file to download, but got 2"):
        job.download_result(tmp_path / "res.tiff")
Exemplo n.º 2
0
def test_download_result_multiple(con100, requests_mock, tmp_path):
    requests_mock.get(API_URL + "/jobs/jj/results",
                      json={
                          "assets": {
                              "1.tiff": {
                                  "href": API_URL + "/dl/jjr1.tiff"
                              },
                              "2.tiff": {
                                  "href": API_URL + "/dl/jjr2.tiff"
                              },
                          }
                      })
    job = RESTJob("jj", connection=con100)
    expected = r"Failed to get single asset \(name None\) from \['1.tiff', '2.tiff'\]"
    with pytest.raises(OpenEoClientException, match=expected):
        job.download_result(tmp_path / "res.tiff")
Exemplo n.º 3
0
def test_download_result(con100, requests_mock, tmp_path):
    requests_mock.get(API_URL + "/jobs/jj/results", json={"assets": {
        "1.tiff": {"href": API_URL + "/dl/jjr1.tiff"},
    }})
    requests_mock.get(API_URL + "/dl/jjr1.tiff", content=TIFF_CONTENT)
    job = RESTJob("jj", connection=con100)
    target = as_path(tmp_path / "result.tiff")
    res = job.download_result(target)
    assert res == target
    with target.open("rb") as f:
        assert f.read() == TIFF_CONTENT
Exemplo n.º 4
0
def test_download_result_folder(con100, requests_mock, tmp_path):
    requests_mock.get(API_URL + "/jobs/jj/results", json={"assets": {
        "1.tiff": {"href": API_URL + "/dl/jjr1.tiff"},
    }})
    requests_mock.get(API_URL + "/dl/jjr1.tiff", content=TIFF_CONTENT)
    job = RESTJob("jj", connection=con100)
    target = as_path(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
Exemplo n.º 5
0
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 = RESTJob("jj", connection=session040)
    assert job.list_results() == {
        'links': [{
            'href': 'https://oeo.test/dl/jjr1.tiff'
        }]
    }
    target = as_path(tmp_path / "result.tiff")
    res = job.download_result(target)
    assert res == target
    with target.open("rb") as f:
        assert f.read() == TIFF_CONTENT