Skip to content

Commit 0e42435

Browse files
committed
Cleanup and black
- use limits api in project limit hit test to allow run this test separately
1 parent 2d03d7d commit 0e42435

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

mergin/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ def projects_list(
668668
order_params=order_params,
669669
only_public=only_public,
670670
)
671-
print(resp["projects"])
672671
fetched_projects += len(resp["projects"])
673672
count = resp["count"]
674673
projects += resp["projects"]

mergin/test/test_client.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,11 @@ def test_available_workspace_storage(mcStorage):
814814
remove_folders([project_dir])
815815

816816
# revert storage limit to default value
817-
mcStorage.patch(f"/v1/tests/workspaces/{client_workspace_id}", {"limits_override": { "storage": current_storage, "projects": 1, "api_allowed": True }}, {"Content-Type": "application/json"})
817+
mcStorage.patch(
818+
f"/v1/tests/workspaces/{client_workspace_id}",
819+
{"limits_override": {"storage": current_storage, "projects": 1, "api_allowed": True}},
820+
{"Content-Type": "application/json"},
821+
)
818822

819823

820824
def test_available_storage_validation2(mc, mc2):
@@ -2670,6 +2674,19 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
26702674
test_project = "test_another_project_above_projects_limit"
26712675
test_project_fullname = STORAGE_WORKSPACE + "/" + test_project
26722676

2677+
client_workspace = None
2678+
for workspace in mcStorage.workspaces_list():
2679+
if workspace["name"] == STORAGE_WORKSPACE:
2680+
client_workspace = workspace
2681+
break
2682+
client_workspace_id = client_workspace["id"]
2683+
client_workspace_storage = client_workspace["storage"]
2684+
mcStorage.patch(
2685+
f"/v1/tests/workspaces/{client_workspace_id}",
2686+
{"limits_override": {"storage": client_workspace_storage, "projects": 0, "api_allowed": True}},
2687+
{"Content-Type": "application/json"},
2688+
)
2689+
26732690
project_dir = os.path.join(TMP_DIR, test_project, API_USER)
26742691

26752692
with pytest.raises(ClientError) as e:
@@ -2682,3 +2699,10 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
26822699
assert e.value.http_error == 422
26832700
assert e.value.http_method == "POST"
26842701
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"
2702+
2703+
# back to original values... (1 project, api allowed ...)
2704+
mcStorage.patch(
2705+
f"/v1/tests/workspaces/{client_workspace_id}",
2706+
{"limits_override": {"storage": client_workspace_storage, "projects": 1, "api_allowed": True}},
2707+
{"Content-Type": "application/json"},
2708+
)

0 commit comments

Comments
 (0)