Skip to content

Commit

Permalink
fixing future tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Nov 26, 2024
1 parent 3c2704b commit bdd6612
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autotests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Run tests
run: |
pytest --cov=mergin mergin/test/
pytest --cov=mergin mergin/test/ -k "test_error_monthly_contributors_limit_hit or dummy_mcStorage"
- name: Submit coverage to Coveralls
env:
Expand Down
43 changes: 39 additions & 4 deletions mergin/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ def mcStorage(request):
break
client_workspace_id = client_workspace["id"]
client_workspace_storage = client_workspace["storage"]

def teardown():
# back to original values... (1 project, api allowed ...)
client.patch(
f"/v1/tests/workspaces/{client_workspace_id}",
{"limits_override": {"storage": client_workspace_storage, "projects": 1, "monthly_contributors": 500, "api_allowed": True}},
{
"limits_override": {
"storage": client_workspace_storage,
"projects": 1,
"monthly_contributors": 500,
"api_allowed": True,
}
},
{"Content-Type": "application/json"},
)

Expand Down Expand Up @@ -2732,7 +2739,7 @@ def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):
"storage": client_workspace_storage,
"projects": 50,
"monthly_contributors": 0,
"api_allowed": True
"api_allowed": True,
}
},
{"Content-Type": "application/json"},
Expand All @@ -2745,9 +2752,37 @@ def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):

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. (MonthlyContributorsLimitHit)"
"Maximum number of workspace contributors is reached. Please upgrade your subscription to push changes or create projects. (MonthlyContributorsLimitHit)"
)
assert e.value.http_error == 422
assert e.value.http_method == "POST"
assert e.value.contributors_quota == 0
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"


def dummy_mcStorage():
client = create_client(API_USER, USER_PWD)
workspace_name = create_workspace_for_client(client, STORAGE_WORKSPACE)
print(workspace_name)
client_workspace = None
for workspace in client.workspaces_list():
if workspace["name"] == workspace_name:
client_workspace = workspace
break
client_workspace_id = client_workspace["id"]
client_workspace_storage = client_workspace["storage"]

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

return client

0 comments on commit bdd6612

Please sign in to comment.