Skip to content

Commit 7998c7b

Browse files
committed
Revert "Merge pull request #221 from MerginMaps/monthlyContributorsError"
This reverts commit 74222e4, reversing changes made to 3cc76f8.
1 parent 1c0ec53 commit 7998c7b

File tree

2 files changed

+6
-49
lines changed

2 files changed

+6
-49
lines changed

mergin/common.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class ErrorCode(Enum):
1515
ProjectsLimitHit = "ProjectsLimitHit"
1616
StorageLimitHit = "StorageLimitHit"
17-
MonthlyContributorsLimitHit = "MonthlyContributorsLimitHit"
1817

1918

2019
class ClientError(Exception):
@@ -37,8 +36,6 @@ def __str__(self):
3736
string_res += f"URL: {self.url}\n"
3837
if self.http_method:
3938
string_res += f"Method: {self.http_method}\n"
40-
if self.server_code:
41-
string_res += f"Error code: {self.server_code}\n"
4239
if self.extra:
4340
string_res += f"{self.extra}\n"
4441
return string_res

mergin/test/test_client.py

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
STORAGE_WORKSPACE = os.environ.get("TEST_STORAGE_WORKSPACE", "testpluginstorage")
5353

5454

55-
def get_limit_overrides(storage: int):
56-
return {"storage": storage, "projects": 2, "api_allowed": True, "monthly_contributors": -1}
57-
58-
5955
@pytest.fixture(scope="function")
6056
def mc():
6157
client = create_client(API_USER, USER_PWD)
@@ -74,6 +70,7 @@ def mc2():
7470
def mcStorage(request):
7571
client = create_client(API_USER, USER_PWD)
7672
workspace_name = create_workspace_for_client(client, STORAGE_WORKSPACE)
73+
print(workspace_name)
7774
client_workspace = None
7875
for workspace in client.workspaces_list():
7976
if workspace["name"] == workspace_name:
@@ -86,7 +83,7 @@ def teardown():
8683
# back to original values... (1 project, api allowed ...)
8784
client.patch(
8885
f"/v1/tests/workspaces/{client_workspace_id}",
89-
{"limits_override": get_limit_overrides(client_workspace_storage)},
86+
{"limits_override": {"storage": client_workspace_storage, "projects": 1, "api_allowed": True}},
9087
{"Content-Type": "application/json"},
9188
)
9289

@@ -2689,10 +2686,8 @@ def test_error_push_already_named_project(mc: MerginClient):
26892686

26902687

26912688
def test_error_projects_limit_hit(mcStorage: MerginClient):
2692-
test_project = "project_above_projects_limit"
2689+
test_project = "test_another_project_above_projects_limit"
26932690
test_project_fullname = STORAGE_WORKSPACE + "/" + test_project
2694-
project_dir = os.path.join(TMP_DIR, test_project, API_USER)
2695-
cleanup(mcStorage, test_project, [project_dir])
26962691

26972692
client_workspace = None
26982693
for workspace in mcStorage.workspaces_list():
@@ -2703,10 +2698,12 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
27032698
client_workspace_storage = client_workspace["storage"]
27042699
mcStorage.patch(
27052700
f"/v1/tests/workspaces/{client_workspace_id}",
2706-
{"limits_override": {**get_limit_overrides(client_workspace_storage), "projects": 0}},
2701+
{"limits_override": {"storage": client_workspace_storage, "projects": 0, "api_allowed": True}},
27072702
{"Content-Type": "application/json"},
27082703
)
27092704

2705+
project_dir = os.path.join(TMP_DIR, test_project, API_USER)
2706+
27102707
with pytest.raises(ClientError) as e:
27112708
mcStorage.create_project_and_push(test_project_fullname, project_dir)
27122709
assert e.value.server_code == ErrorCode.ProjectsLimitHit.value
@@ -2719,43 +2716,6 @@ def test_error_projects_limit_hit(mcStorage: MerginClient):
27192716
assert e.value.url == f"{mcStorage.url}v1/project/testpluginstorage"
27202717

27212718

2722-
# TODO: refactor tests to create workspaces on each run and apply test_error_monthly_contributors_limit_hit
2723-
def test_error_monthly_contributors_limit_hit(mcStorage: MerginClient):
2724-
test_project = "test_monthly_contributors_limit_hit"
2725-
project_dir = os.path.join(TMP_DIR, test_project)
2726-
test_project_fullname = STORAGE_WORKSPACE + "/" + test_project
2727-
cleanup(mcStorage, test_project_fullname, [project_dir])
2728-
2729-
client_workspace = None
2730-
for workspace in mcStorage.workspaces_list():
2731-
if workspace["name"] == STORAGE_WORKSPACE:
2732-
client_workspace = workspace
2733-
break
2734-
2735-
client_workspace_id = client_workspace["id"]
2736-
client_workspace_storage = client_workspace["storage"]
2737-
mcStorage.patch(
2738-
f"/v1/tests/workspaces/{client_workspace_id}",
2739-
{"limits_override": {**get_limit_overrides(client_workspace_storage), "monthly_contributors": 0}},
2740-
{"Content-Type": "application/json"},
2741-
)
2742-
2743-
mcStorage.create_project_and_push(test_project_fullname, project_dir)
2744-
shutil.copy(os.path.join(TEST_DATA_DIR, "test.txt"), project_dir)
2745-
with pytest.raises(ClientError) as e:
2746-
mcStorage.push_project(project_dir)
2747-
2748-
assert e.value.server_code == ErrorCode.MonthlyContributorsLimitHit.value
2749-
assert e.value.detail == (
2750-
"Maximum number of workspace contributors is reached. "
2751-
"Please upgrade your subscription to push changes or create projects. (MonthlyContributorsLimitHit)"
2752-
)
2753-
assert e.value.http_error == 422
2754-
assert e.value.http_method == "POST"
2755-
assert e.value.url == f"{mcStorage.url}v1/project/push/testpluginstorage/{test_project}"
2756-
assert e.value.server_response.get("contributors_quota") == 0
2757-
2758-
27592719
def test_workspace_requests(mc2: MerginClient):
27602720
test_project = "test_permissions"
27612721
test_project_fullname = API_USER2 + "/" + test_project

0 commit comments

Comments
 (0)