Skip to content

Commit

Permalink
Issue #404 Minor clarifications in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanKJSchreurs committed Oct 4, 2023
1 parent f8d523c commit 455632d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/rest/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3259,12 +3259,17 @@ def validation(request, context):
def test_download_pg_json_handles_other_exception_during_validation_gracefully(
self, requests_mock, connection_with_pgvalidation, tmp_path, pg_json: str, caplog
):
"""Verify the job won't be blocked if errors occur during validation that are
not related to the validity of the graph, e.g. the HTTP request itself fails, etc.
Because we don't want to break the existing workflows.
"""
caplog.set_level(logging.WARNING)
requests_mock.post(API_URL + "result", content=self._post_result_handler_tiff_invalid_pg)

exception_message = "Testing for errors that are not due to invalid graphs."
exception_message = "Exception to test for errors that are not due to invalid graphs."

def validation(request, context):
# Simulate some random error during the request.
raise Exception(exception_message)

m = requests_mock.post(API_URL + "validation", json=validation)
Expand All @@ -3273,9 +3278,10 @@ def validation(request, context):
connection_with_pgvalidation.download(pg_json, outputfile=output, validate=True)

assert output.read_bytes() == b"TIFF data"
assert m.call_count == 1
# We still want to see those warnings in the logs though:
assert caplog.messages[0].startswith("Could not validate the process graph")
assert caplog.text.endswith(exception_message + "\n")
assert m.call_count == 1

@pytest.mark.parametrize("pg_json", [PG_JSON_1, PG_JSON_2])
def test_execute_pg_json(self, requests_mock, pg_json: str):
Expand Down

0 comments on commit 455632d

Please sign in to comment.