diff --git a/server/mergin/tests/test_private_project_api.py b/server/mergin/tests/test_private_project_api.py index f9ac4452..5d5ec518 100644 --- a/server/mergin/tests/test_private_project_api.py +++ b/server/mergin/tests/test_private_project_api.py @@ -418,61 +418,3 @@ def test_admin_project_list(client): p.delete() resp = client.get("/app/admin/projects?page=1&per_page=15&like=mergin") assert len(resp.json["items"]) == 14 - - -def test_get_project_access(client): - workspace = create_workspace() - user = User.query.filter(User.username == "mergin").first() - project = create_project("test-project", workspace, user) - url = f"/app/project/{project.id}/access" - users = [] - for i in range(5): - users.append(add_user(str(i), str(i))) - Configuration.GLOBAL_ADMIN = False - Configuration.GLOBAL_WRITE = False - Configuration.GLOBAL_READ = False - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 1 - assert resp.json[0]["role"] == "owner" - project.set_role(users[0].id, ProjectRole.OWNER) - project.set_role(users[1].id, ProjectRole.WRITER) - project.set_role(users[2].id, ProjectRole.READER) - db.session.commit() - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 4 - assert sum(map(lambda x: int(x["role"] == "owner"), resp.json)) == 2 - assert sum(map(lambda x: int(x["role"] == "writer"), resp.json)) == 1 - assert sum(map(lambda x: int(x["role"] == "reader"), resp.json)) == 1 - # user3 does not have access to the project - assert not any(users[3].email == access["email"] for access in resp.json) - assert any(users[2].email == access["email"] for access in resp.json) - Configuration.GLOBAL_READ = True - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 6 - assert sum(map(lambda x: int(x["role"] == "owner"), resp.json)) == 2 - assert sum(map(lambda x: int(x["role"] == "writer"), resp.json)) == 1 - assert sum(map(lambda x: int(x["role"] == "reader"), resp.json)) == 3 - Configuration.GLOBAL_WRITE = True - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 6 - assert sum(map(lambda x: int(x["role"] == "owner"), resp.json)) == 2 - assert sum(map(lambda x: int(x["role"] == "writer"), resp.json)) == 4 - assert sum(map(lambda x: int(x["role"] == "reader"), resp.json)) == 0 - Configuration.GLOBAL_ADMIN = True - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 6 - assert sum(map(lambda x: int(x["role"] == "owner"), resp.json)) == 6 - assert sum(map(lambda x: int(x["role"] == "writer"), resp.json)) == 0 - assert sum(map(lambda x: int(x["role"] == "reader"), resp.json)) == 0 - # pretend a user was deleted to test that api can handle it - users[3].inactivate() - users[3].anonymize() - resp = client.get(url) - assert resp.status_code == 200 - assert len(resp.json) == 5 - assert sum(map(lambda x: int(x["role"] == "owner"), resp.json)) == 5