Skip to content

Commit 4387b41

Browse files
committed
adding test_error_monthly_contributors_limit_hit
1 parent 3f41a61 commit 4387b41

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

mergin/test/test_client.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,3 +2711,36 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
27112711
assert e.value.http_error == 422
27122712
assert e.value.http_method == "POST"
27132713
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"
2714+
2715+
2716+
def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):
2717+
test_project = "test_another_project_above_monthly_contributors_limit_hit"
2718+
test_project_fullname = STORAGE_WORKSPACE + "/" + test_project
2719+
2720+
client_workspace = None
2721+
for workspace in mcStorage.workspaces_list():
2722+
if workspace["name"] == STORAGE_WORKSPACE:
2723+
client_workspace = workspace
2724+
break
2725+
2726+
client_workspace_id = client_workspace["id"]
2727+
mcStorage.patch(
2728+
f"/v1/tests/workspaces/{client_workspace_id}",
2729+
{"limits_override": {"monthly_contributors": 0, "api_allowed": True}},
2730+
{"Content-Type": "application/json"},
2731+
)
2732+
2733+
project_dir = os.path.join(TMP_DIR, test_project, API_USER)
2734+
2735+
with pytest.raises(ClientError) as e:
2736+
mcStorage.create_project_and_push(test_project_fullname, project_dir)
2737+
2738+
assert e.value.server_code == ErrorCode.MonthlyContributorsLimitHit.value
2739+
assert e.value.detail == (
2740+
"Maximum number of workspace contributors is reached. "
2741+
"Please upgrade your subscription to push changes or create projects."
2742+
)
2743+
assert e.value.http_error == 422
2744+
assert e.value.http_method == "POST"
2745+
assert e.value.url == f"{mc.url}v1/project/{API_USER}"
2746+
assert e.value.contributors_quota == 0

0 commit comments

Comments
 (0)