From cd2d56c436e8597c2979707e7b563feaaa73a7b9 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Fri, 6 Dec 2024 13:23:57 +0100 Subject: [PATCH 1/3] Fix using json module load from onject instead of string --- mergin/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mergin/client.py b/mergin/client.py index 28800e21..8c7d4a4a 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -344,7 +344,7 @@ def workspace_service(self, workspace_id): Returns response from server as JSON dict or None if endpoint is not found """ resp = self.get(f"/v1/workspace/{workspace_id}/service") - return json.loads(resp) + return json.load(resp) def workspace_usage(self, workspace_id): """ From 0c71e5359c3455ed3261f57cc0ee1e1073d6ff79 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Tue, 14 Jan 2025 13:20:04 +0100 Subject: [PATCH 2/3] Add tests to workspace_* functions --- mergin/test/test_client.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index 826e2aae..37cefa4e 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -2754,3 +2754,32 @@ def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient): assert e.value.http_method == "POST" assert e.value.url == f"{mcStorage.url}v1/project/push/testpluginstorage/{test_project}" assert e.value.server_response.get("contributors_quota") == 0 + + +def test_workspace_requests(mc2: MerginClient): + test_project = "test_permissions" + test_project_fullname = API_USER2 + "/" + test_project + + project_info = mc2.project_info(test_project_fullname) + ws_id = project_info.get("workspace_id") + + usage = mc2.workspace_usage(ws_id) + # Check type and common value + assert type(usage) == dict + assert usage["api"]["allowed"] == True + assert usage["history"]["quota"] == 214748364800 + assert usage["history"]["usage"] == 0 + + service = mc2.workspace_service(ws_id) + # Check type and common value + assert type(service) == dict + assert service["action_required"] == False + assert service["plan"] + assert service["plan"]["is_paid_plan"] == False + assert service["plan"]["product_id"] == None + assert service["plan"]["type"] == 'custom' + assert service["subscription"] == None + + + + From 1c0ec53fb3ab5588abadd619143abf2e67fef66f Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Tue, 14 Jan 2025 13:21:41 +0100 Subject: [PATCH 3/3] style --- mergin/test/test_client.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index 37cefa4e..260fafd8 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -2763,23 +2763,19 @@ def test_workspace_requests(mc2: MerginClient): project_info = mc2.project_info(test_project_fullname) ws_id = project_info.get("workspace_id") - usage = mc2.workspace_usage(ws_id) + usage = mc2.workspace_usage(ws_id) # Check type and common value assert type(usage) == dict assert usage["api"]["allowed"] == True assert usage["history"]["quota"] == 214748364800 assert usage["history"]["usage"] == 0 - service = mc2.workspace_service(ws_id) + service = mc2.workspace_service(ws_id) # Check type and common value assert type(service) == dict assert service["action_required"] == False assert service["plan"] assert service["plan"]["is_paid_plan"] == False assert service["plan"]["product_id"] == None - assert service["plan"]["type"] == 'custom' + assert service["plan"]["type"] == "custom" assert service["subscription"] == None - - - -