Skip to content

Commit

Permalink
fixup! Issue #332/#374 follow up
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Feb 10, 2023
1 parent 0ceced3 commit e4767b3
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions tests/rest/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,25 @@ def test_execute_batch_with_error(con100, requests_mock, tmpdir):
requests_mock.get(API_URL + "/collections/SENTINEL2", json={"foo": "bar"})
requests_mock.post(API_URL + "/jobs", status_code=201, headers={"OpenEO-Identifier": "f00ba5"})
requests_mock.post(API_URL + "/jobs/f00ba5/results", status_code=202)
requests_mock.get(API_URL + "/jobs/f00ba5", [
{'json': {"status": "submitted"}},
{'json': {"status": "queued"}},
{'json': {"status": "running", "progress": 15}},
{'json': {"status": "running", "progress": 80}},
{'json': {"status": "error", "progress": 100}},
])
requests_mock.get(API_URL + "/jobs/f00ba5/logs", json={
'logs': [{
'id': "123abc",
'level': 'error',
'message': "error processing batch job"
}]
})
requests_mock.get(
API_URL + "/jobs/f00ba5",
[
{"json": {"status": "submitted"}},
{"json": {"status": "queued"}},
{"json": {"status": "running", "progress": 15}},
{"json": {"status": "running", "progress": 80}},
{"json": {"status": "error", "progress": 100}},
],
)
requests_mock.get(
API_URL + "/jobs/f00ba5/logs",
json={
"logs": [
{"id": "12", "level": "info", "message": "starting"},
{"id": "34", "level": "error", "message": "nope"},
]
},
)

path = tmpdir.join("tmp.tiff")
log = []
Expand All @@ -125,10 +130,10 @@ def test_execute_batch_with_error(con100, requests_mock, tmpdir):
except JobFailedException as e:
assert e.job.status() == "error"
assert [(l.level, l.message) for l in e.job.logs()] == [
("error", "error processing batch job"),
("info", "starting"),
("error", "nope"),
]


assert log == [
"0:00:01 Job 'f00ba5': send 'start'",
"0:00:02 Job 'f00ba5': submitted (progress N/A)",
Expand All @@ -137,7 +142,7 @@ def test_execute_batch_with_error(con100, requests_mock, tmpdir):
"0:00:12 Job 'f00ba5': running (progress 80%)",
"0:00:20 Job 'f00ba5': error (progress 100%)",
"Your batch job 'f00ba5' failed. Error logs:",
[{"id": "123abc", "level": "error", "message": "error processing batch job"}],
[{"id": "34", "level": "error", "message": "nope"}],
"Full logs can be inspected in an openEO (web) editor or with `connection.job('f00ba5').logs()`.",
]

Expand Down

0 comments on commit e4767b3

Please sign in to comment.