From 5740d7904ef0ada58867b1d48282fd326bb9e10b Mon Sep 17 00:00:00 2001 From: Brad Macdonald Date: Wed, 25 Oct 2023 12:21:27 -0600 Subject: [PATCH] updates pagination --- src/orca/services/nextflowtower/client.py | 6 ++++-- tests/services/nextflowtower/test_client.py | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/orca/services/nextflowtower/client.py b/src/orca/services/nextflowtower/client.py index da0c668..5ac4f92 100644 --- a/src/orca/services/nextflowtower/client.py +++ b/src/orca/services/nextflowtower/client.py @@ -113,7 +113,9 @@ def request_paged(self, method: str, path: str, **kwargs) -> dict[str, Any]: while num_items < total_size: kwargs["params"]["offset"] = num_items json = self.request_json(method, path, **kwargs) - total_size = json.pop("totalSize") + total_size = ( + json.pop("totalSize") if json.get("totalSize") else json.pop("total") + ) key_name, items = json.popitem() num_items += len(items) all_items.extend(items) @@ -134,7 +136,7 @@ def get(self, path: str, **kwargs) -> dict[str, Any]: A dictionary from deserializing the JSON response. """ json = self.request_json("GET", path, **kwargs) - if "totalSize" in json: + if "totalSize" in json or "total" in json: json = self.request_paged("GET", path, **kwargs) return json diff --git a/tests/services/nextflowtower/test_client.py b/tests/services/nextflowtower/test_client.py index cf487d3..df16981 100644 --- a/tests/services/nextflowtower/test_client.py +++ b/tests/services/nextflowtower/test_client.py @@ -155,7 +155,6 @@ def test_that_get_workflow_tasks_works(client, mocker, get_response): mock.return_value = get_response("get_workflow_tasks") result = client.get_workflow_tasks(workspace_id=98765, workflow_id="123456789") mock.assert_called() - print(result) assert len(result) == 4