Skip to content

Commit

Permalink
ci: Add require_serial to pylint pre-commit
Browse files Browse the repository at this point in the history
Leads to better correctness according to the pylint docs.
  • Loading branch information
MoritzWeber0 committed Nov 13, 2024
1 parent 8e3c71a commit 4e60f6d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 109 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ repos:
- id: pylint
name: pylint
entry: pylint
args: [--rcfile=./backend/pyproject.toml]
args: [
'-rn', # Only display messages
'-sn', # Don't display the score
'--rcfile=./backend/pyproject.toml',
]
language: system
types: [python]
require_serial: true
files: '^backend'
exclude: '^backend/capellacollab/alembic/'
- repo: local
Expand Down
48 changes: 14 additions & 34 deletions backend/tests/projects/test_projects_users_routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

import pytest
from fastapi import testclient
from sqlalchemy import orm

Expand All @@ -12,32 +13,25 @@
from capellacollab.users import models as users_models


@pytest.mark.usefixtures("admin")
def test_assign_read_write_permission_when_adding_manager(
db: orm.Session,
client: testclient.TestClient,
executor_name: str,
unique_username: str,
user2: users_models.DatabaseUser,
project: projects_models.DatabaseProject,
):
users_crud.create_user(
db, executor_name, executor_name, None, users_models.Role.ADMIN
)
user = users_crud.create_user(
db, unique_username, unique_username, None, users_models.Role.USER
)

response = client.post(
f"/api/v1/projects/{project.slug}/users/",
json={
"role": projects_users_models.ProjectUserRole.MANAGER.value,
"permission": projects_users_models.ProjectUserPermission.READ.value,
"username": user.name,
"username": user2.name,
"reason": "",
},
)

project_user = projects_users_crud.get_project_user_association(
db, project, user
db, project, user2
)

assert response.status_code == 200
Expand All @@ -49,38 +43,31 @@ def test_assign_read_write_permission_when_adding_manager(
)


@pytest.mark.usefixtures("admin")
def test_assign_read_write_permission_when_changing_project_role_to_manager(
db: orm.Session,
client: testclient.TestClient,
executor_name: str,
unique_username: str,
project: projects_models.DatabaseProject,
user2: users_models.DatabaseUser,
):
users_crud.create_user(
db, executor_name, executor_name, None, users_models.Role.ADMIN
)
user = users_crud.create_user(
db, unique_username, unique_username, None, users_models.Role.USER
)

projects_users_crud.add_user_to_project(
db,
project,
user,
user2,
projects_users_models.ProjectUserRole.USER,
projects_users_models.ProjectUserPermission.READ,
)

response = client.patch(
f"/api/v1/projects/{project.slug}/users/{user.id}",
f"/api/v1/projects/{project.slug}/users/{user2.id}",
json={
"role": projects_users_models.ProjectUserRole.MANAGER.value,
"reason": "",
},
)

project_user = projects_users_crud.get_project_user_association(
db, project, user
db, project, user2
)

assert response.status_code == 204
Expand All @@ -92,30 +79,23 @@ def test_assign_read_write_permission_when_changing_project_role_to_manager(
)


@pytest.mark.usefixtures("admin")
def test_http_exception_when_updating_permission_of_manager(
db: orm.Session,
client: testclient.TestClient,
executor_name: str,
unique_username: str,
user2: users_models.DatabaseUser,
project: projects_models.DatabaseProject,
):
users_crud.create_user(
db, executor_name, executor_name, None, users_models.Role.ADMIN
)
user = users_crud.create_user(
db, unique_username, unique_username, None, users_models.Role.USER
)

projects_users_crud.add_user_to_project(
db,
project,
user,
user2,
projects_users_models.ProjectUserRole.MANAGER,
projects_users_models.ProjectUserPermission.WRITE,
)

response = client.patch(
f"/api/v1/projects/{project.slug}/users/{user.id}",
f"/api/v1/projects/{project.slug}/users/{user2.id}",
json={
"permission": projects_users_models.ProjectUserPermission.READ.value,
"reason": "",
Expand Down
Loading

0 comments on commit 4e60f6d

Please sign in to comment.