Skip to content

Commit

Permalink
Issue #134 drop pre-1.0.0 support from _build_request_with_process_graph
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 7, 2023
1 parent 635cc2b commit ac4ab09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
10 changes: 4 additions & 6 deletions openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,10 @@ def _build_request_with_process_graph(self, process_graph: Union[dict, Any], **k
"""
result = kwargs
process_graph = as_flat_graph(process_graph)
if self._api_version.at_least("1.0.0"):
if "process_graph" not in process_graph:
process_graph = {"process_graph": process_graph}
result["process"] = process_graph
else:
result["process_graph"] = process_graph
assert self._api_version.at_least("1.0.0")
if "process_graph" not in process_graph:
process_graph = {"process_graph": process_graph}
result["process"] = process_graph
return result

# TODO: unify `download` and `execute` better: e.g. `download` always writes to disk, `execute` returns result (raw or as JSON decoded dict)
Expand Down
12 changes: 0 additions & 12 deletions tests/rest/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1967,18 +1967,6 @@ def test_default_timeout(requests_mock):
assert conn.get("/foo", timeout=5).json() == '5'


def test_execute_042(requests_mock):
requests_mock.get(API_URL, json={"api_version": "0.4.2"})
conn = Connection(API_URL)
with mock.patch.object(conn, "request") as request:
conn.execute({"foo1": {"process_id": "foo"}})
assert request.call_args_list == [
mock.call(
"post", path="/result", allow_redirects=False, expected_status=200,
json={"process_graph": {"foo1": {"process_id": "foo"}}}
)
]


@pytest.mark.parametrize("pg", [
{"foo1": {"process_id": "foo"}},
Expand Down
5 changes: 4 additions & 1 deletion tests/test_usecase1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

@requests_mock.mock()
class TestUsecase1(TestCase):
_capabilities = {"api_version": "0.4.0", "endpoints": [{"path": "/credentials/basic", "methods": ["GET"]}]}
_capabilities = {
"api_version": "1.0.0",
"endpoints": [{"path": "/credentials/basic", "methods": ["GET"]}],
}

def setUp(self):
# configuration phase: define username, endpoint, parameters?
Expand Down

0 comments on commit ac4ab09

Please sign in to comment.