From f018a506f23ff8ac1a56677cbff30ac76c18d08a Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Tue, 3 Dec 2024 10:59:39 +0100 Subject: [PATCH] Adressed last comments --- mergin/client.py | 10 +++++----- mergin/test/test_client.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mergin/client.py b/mergin/client.py index 56918f3..11558d4 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -383,8 +383,8 @@ def workspace_usage(self, workspace_id): try: response = self.get(f"/v1/workspace/{workspace_id}/usage") except ClientError as e: - self.log.debug(f"Unable to query for /workspace/{workspace_id}/usage endpoint") - return + e.extra = f"Unable to query for /workspace/{workspace_id}/usage endpoint" + raise e response = json.loads(response.read()) @@ -718,7 +718,7 @@ def project_info(self, project_path_or_id, since=None, version=None): resp = self.get("/v1/project/{}".format(project_path_or_id), params) return json.load(resp) - def project_versions_page(self, project_path, page, per_page=100, descending=False): + def paginated_project_versions(self, project_path, page, per_page=100, descending=False): """ Get records of project's versions (history) using calculated pagination. wrapper around the /v1/project/versions/paginated/{} API end point @@ -786,7 +786,7 @@ def project_versions(self, project_path, since=1, to=None): start_page = math.ceil(num_since / per_page) if not num_to: # let's get first page and count - versions, num_to = self.project_versions_page(project_path, start_page, per_page) + versions, num_to = self.paginated_project_versions(project_path, start_page, per_page) latest_version = int_version(versions[-1]["name"]) if latest_version < num_to: @@ -794,7 +794,7 @@ def project_versions(self, project_path, since=1, to=None): else: end_page = math.ceil(num_to / per_page) for page in range(start_page, end_page + 1): - page_versions, _ = self.project_versions_page(project_path, page, per_page) + page_versions, _ = self.paginated_project_versions(project_path, page, per_page) versions += page_versions # filter out versions not within range diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index 1e8ee1e..5ae3f3b 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -2016,7 +2016,7 @@ def test_project_versions_list(mc): versions_count = mc.project_versions_count(project) assert versions_count == 5 - versions, _ = mc.project_versions_page(project, page=1, descending=True) + versions, _ = mc.paginated_project_versions(project, page=1, descending=True) assert len(versions) == 5 assert versions[0]["name"] == "v5" assert versions[-1]["name"] == "v1"