Skip to content

Commit

Permalink
fixup! Issue #297 Improve compliance with 'remote-udp' extension
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Jul 8, 2024
1 parent 9b99f4f commit 27d6587
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion openeo_driver/ProcessGraphDeserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ def evaluate_process_from_url(process_id: str, namespace: str, args: dict, env:
raise OpenEOApiException(
status_code=400,
code="ProcessNamespaceInvalid",
message=f"The value passed for namespace '{namespace}' in process '{process_id}' is invalid: {e}",
message=f"Process '{process_id}' specified with invalid namespace '{namespace}': {e!r}",
) from e

return _evaluate_process_graph_process(
Expand Down
4 changes: 3 additions & 1 deletion openeo_driver/processgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def get_process_definition_from_url(process_id: str, url: str) -> ProcessDefinit
spec = found[0]
else:
raise OpenEOApiException(
status_code=400, code="ProcessNotFound", message=f"Process {process_id!r} not found in {url!r}."
status_code=400,
code="ProcessNotFound",
message=f"No valid process definition for {process_id!r} found at {url!r}.",
)

return ProcessDefinition(
Expand Down
22 changes: 14 additions & 8 deletions tests/test_views_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Iterable, Optional
from unittest import mock, skip
from zipfile import ZipFile
import http.client

import geopandas as gpd
import numpy as np
Expand Down Expand Up @@ -2708,26 +2709,27 @@ def test_discard_result(api):
"https://oeo.test/u/42/udp/bbox_mol",
{"https://oeo.test/u/42/udp/bbox_mol": 404},
(
400, "ProcessUnsupported",
"'bbox_mol' is not available in namespace 'https://oeo.test/u/42/udp/bbox_mol'."
400,
"ProcessNamespaceInvalid",
"Process 'bbox_mol' specified with invalid namespace 'https://oeo.test/u/42/udp/bbox_mol': HTTPError('404 Client Error: Not Found for url: https://oeo.test/u/42/udp/bbox_mol')",
),
),
(
"https://oeo.test/u/42/udp/bbox_mol",
{"https://oeo.test/u/42/udp/bbox_mol": {"foo": "bar"}},
(
400,
"ProcessResourceInvalid",
"Failed to load process 'bbox_mol' from 'https://oeo.test/u/42/udp/bbox_mol': KeyError('id')",
"ProcessNotFound",
"No valid process definition for 'bbox_mol' found at 'https://oeo.test/u/42/udp/bbox_mol'.",
),
),
(
"https://oeo.test/u/42/udp/bbox_mol",
{"https://oeo.test/u/42/udp/bbox_mol": '{"foo": invalid json'},
(
400,
"ProcessResourceInvalid",
"Failed to load process 'bbox_mol' from 'https://oeo.test/u/42/udp/bbox_mol': JSONDecodeError",
"ProcessNamespaceInvalid",
"Process 'bbox_mol' specified with invalid namespace 'https://oeo.test/u/42/udp/bbox_mol': JSONDecodeError('Expecting value: line 1 column 9 (char 8)')",
),
),
(
Expand All @@ -2737,7 +2739,11 @@ def test_discard_result(api):
"pg/1.0/udp/bbox_mol.json", preprocess=lambda t: t.replace("bbox_mol", "BBox_Mol")
)
},
None,
(
400,
"ProcessIdMismatch",
"Mismatch between expected process 'bbox_mol' and process 'BBox_Mol' defined at 'https://share.example/u42/bbox_mol.json'.",
),
),
(
"https://share.example/u42/bbox_mol.json",
Expand Down Expand Up @@ -2765,7 +2771,7 @@ def test_evaluate_process_from_url(api, requests_mock, namespace, url_mocks, exp
elif isinstance(value, dict):
requests_mock.get(url, json=value)
elif value in [404, 500]:
requests_mock.get(url, status_code=value)
requests_mock.get(url, status_code=value, reason=http.client.responses.get(value))
elif isinstance(value, tuple) and value[0] in [302]:
status_code, target = value
requests_mock.get(url, status_code=status_code, headers={"Location": target})
Expand Down

0 comments on commit 27d6587

Please sign in to comment.