From 41ae3acdf7241027ee83cfac674fa99d940e0818 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Wed, 15 Jan 2025 17:50:21 +0100 Subject: [PATCH 1/2] Partial reverse of 74222e4 to remove the monthly contributor error dialog --- mergin/common.py | 1 - mergin/test/test_client.py | 39 +------------------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/mergin/common.py b/mergin/common.py index f97ddb37..4a10ee33 100644 --- a/mergin/common.py +++ b/mergin/common.py @@ -14,7 +14,6 @@ class ErrorCode(Enum): ProjectsLimitHit = "ProjectsLimitHit" StorageLimitHit = "StorageLimitHit" - MonthlyContributorsLimitHit = "MonthlyContributorsLimitHit" class ClientError(Exception): diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index 826e2aae..71316b8d 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -53,7 +53,7 @@ def get_limit_overrides(storage: int): - return {"storage": storage, "projects": 2, "api_allowed": True, "monthly_contributors": -1} + return {"storage": storage, "projects": 2, "api_allowed": True} @pytest.fixture(scope="function") @@ -2717,40 +2717,3 @@ def test_error_projects_limit_hit(mcStorage: MerginClient): assert e.value.http_error == 422 assert e.value.http_method == "POST" assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage" - - -# TODO: refactor tests to create workspaces on each run and apply test_error_monthly_contributors_limit_hit -def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient): - test_project = "test_monthly_contributors_limit_hit" - project_dir = os.path.join(TMP_DIR, test_project) - test_project_fullname = STORAGE_WORKSPACE + "/" + test_project - cleanup(mcStorage, test_project_fullname, [project_dir]) - - client_workspace = None - for workspace in mcStorage.workspaces_list(): - if workspace["name"] == STORAGE_WORKSPACE: - client_workspace = workspace - break - - client_workspace_id = client_workspace["id"] - client_workspace_storage = client_workspace["storage"] - mcStorage.patch( - f"/v1/tests/workspaces/{client_workspace_id}", - {"limits_override": {**get_limit_overrides(client_workspace_storage), "monthly_contributors": 0}}, - {"Content-Type": "application/json"}, - ) - - mcStorage.create_project_and_push(test_project_fullname, project_dir) - shutil.copy(os.path.join(TEST_DATA_DIR, "test.txt"), project_dir) - with pytest.raises(ClientError) as e: - mcStorage.push_project(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. (MonthlyContributorsLimitHit)" - ) - assert e.value.http_error == 422 - assert e.value.http_method == "POST" - assert e.value.url == f"{mcStorage.url}v1/project/push/testpluginstorage/{test_project}" - assert e.value.server_response.get("contributors_quota") == 0 From ea7ef0eb7f45f4e21b472c219b8851716fc79908 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Thu, 16 Jan 2025 10:44:48 +0100 Subject: [PATCH 2/2] style --- mergin/test/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index f913bcd2..f8934298 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -2718,6 +2718,7 @@ def test_error_projects_limit_hit(mcStorage: MerginClient): assert e.value.http_method == "POST" assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage" + def test_workspace_requests(mc2: MerginClient): test_project = "test_permissions" test_project_fullname = API_USER2 + "/" + test_project @@ -2741,4 +2742,3 @@ def test_workspace_requests(mc2: MerginClient): assert service["plan"]["product_id"] == None assert service["plan"]["type"] == "custom" assert service["subscription"] == None -