Skip to content

Commit 0413f86

Browse files
authored
Merge pull request #225 from MerginMaps/fix-typo-parsing
Fail in last PR regarding the use of json module
2 parents 1381e42 + 1c0ec53 commit 0413f86

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

mergin/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def workspace_service(self, workspace_id):
298298
Returns response from server as JSON dict or None if endpoint is not found
299299
"""
300300
resp = self.get(f"/v1/workspace/{workspace_id}/service")
301-
return json.loads(resp)
301+
return json.load(resp)
302302

303303
def workspace_usage(self, workspace_id):
304304
"""

mergin/test/test_client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,3 +2754,28 @@ def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):
27542754
assert e.value.http_method == "POST"
27552755
assert e.value.url == f"{mcStorage.url}v1/project/push/testpluginstorage/{test_project}"
27562756
assert e.value.server_response.get("contributors_quota") == 0
2757+
2758+
2759+
def test_workspace_requests(mc2: MerginClient):
2760+
test_project = "test_permissions"
2761+
test_project_fullname = API_USER2 + "/" + test_project
2762+
2763+
project_info = mc2.project_info(test_project_fullname)
2764+
ws_id = project_info.get("workspace_id")
2765+
2766+
usage = mc2.workspace_usage(ws_id)
2767+
# Check type and common value
2768+
assert type(usage) == dict
2769+
assert usage["api"]["allowed"] == True
2770+
assert usage["history"]["quota"] == 214748364800
2771+
assert usage["history"]["usage"] == 0
2772+
2773+
service = mc2.workspace_service(ws_id)
2774+
# Check type and common value
2775+
assert type(service) == dict
2776+
assert service["action_required"] == False
2777+
assert service["plan"]
2778+
assert service["plan"]["is_paid_plan"] == False
2779+
assert service["plan"]["product_id"] == None
2780+
assert service["plan"]["type"] == "custom"
2781+
assert service["subscription"] == None

0 commit comments

Comments
 (0)