Skip to content

Commit

Permalink
test attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Nov 25, 2024
1 parent a79c081 commit d62273d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions mergin/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2713,32 +2713,41 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"


def test_error_monthly_contributors_limit_hit(mc: MerginClient):
test_project = "test_project_monthly_contributors_limit_hit"
test_project_fullname = API_USER + "/" + test_project
def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):
test_project = "test_monthly_contributors_limit"
test_project_fullname = STORAGE_WORKSPACE + "/" + test_project

client_workspace = None
for workspace in mc.workspaces_list():
if workspace["name"] == API_USER:
for workspace in mcStorage.workspaces_list():
if workspace["name"] == STORAGE_WORKSPACE:
client_workspace = workspace
break

client_workspace_id = client_workspace["id"]
mc.patch(
client_workspace_storage = client_workspace["storage"]

mcStorage.patch(
f"/v1/tests/workspaces/{client_workspace_id}",
{"limits_override": {"monthly_contributors": 0}},
{
"limits_override": {
"storage": client_workspace_storage,
"monthly_contributors": 0,
"api_allowed": True
}
},
{"Content-Type": "application/json"},
)

with pytest.raises(ClientError) as e:
mc.create_project(test_project_fullname)
project_dir = os.path.join(TMP_DIR, test_project, API_USER)

with pytest.raises(ClientError) as e:
mcStorage.create_project_and_push(test_project_fullname, project_dir)

assert e.value.server_code == ErrorCode.MonthlyContributorsLimitHit.value
assert e.value.detail == (
"Maximum number of workspace contributors is reached. "
"Please upgrade your subscription to push changes or create projects."
)
assert e.value.http_error == 422
assert e.value.http_method == "POST"
assert e.value.url == f"{mcStorage.url}v1/project/{API_USER}"
assert e.value.contributors_quota == 0
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"

0 comments on commit d62273d

Please sign in to comment.