Skip to content

Commit

Permalink
Format backend code base and pin ruff's version to 0.9.0 in CI (#1346)
Browse files Browse the repository at this point in the history
* Format backend code base

* Pin ruff's version to 0.9.0 in CI
  • Loading branch information
ab-smith authored Jan 9, 2025
1 parent 3eea302 commit 8652818
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Install ruff
working-directory: ${{env.working-directory}}
run: |
python -m pip install ruff
python -m pip install ruff==0.9.0
- name: Run ruff format check
working-directory: ${{env.working-directory}}
run: ruff format --check .
Expand Down
18 changes: 9 additions & 9 deletions backend/app_tests/api/test_api_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def test_import_frameworks(self, test):
lib_detail_response = lib_detail_response["framework"]

# Asserts that the library is not already loaded
assert (
Framework.objects.all().count() == 0
), "libraries are already loaded in the database"
assert Framework.objects.all().count() == 0, (
"libraries are already loaded in the database"
)
EndpointTestsQueries.Auth.get_object(
test.client,
"Frameworks",
Expand Down Expand Up @@ -114,9 +114,9 @@ def test_delete_frameworks(self, test):
"""test to delete frameworks with the API with authentication"""

EndpointTestsQueries.Auth.import_object(test.admin_client, "Framework")
assert (
Framework.objects.all().count() == 1
), "Frameworks are not correctly imported in the database"
assert Framework.objects.all().count() == 1, (
"Frameworks are not correctly imported in the database"
)

EndpointTestsQueries.Auth.delete_object(
test.client,
Expand All @@ -140,9 +140,9 @@ def test_import_risk_matrix(self, test):
lib_detail_response = lib_detail_response["risk_matrix"][0]

# Asserts that the library is not already loaded
assert (
RiskMatrix.objects.all().count() == 0
), "libraries are already loaded in the database"
assert RiskMatrix.objects.all().count() == 0, (
"libraries are already loaded in the database"
)
EndpointTestsQueries.Auth.get_object(
test.client, "Risk matrices", user_group=test.user_group
)
Expand Down
6 changes: 3 additions & 3 deletions backend/app_tests/api/test_api_user_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def test_group_permissions(self, test):
User.objects.get(email=TEST_USER_EMAIL)
)
for perm in GROUPS_PERMISSIONS[test.user_group]["perms"]:
assert (
perm in user_permissions.keys()
), f"Permission {perm} not found in user permissions (group: {test.user_group})"
assert perm in user_permissions.keys(), (
f"Permission {perm} not found in user permissions (group: {test.user_group})"
)
24 changes: 12 additions & 12 deletions backend/app_tests/api/test_api_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ def test_uniqueness_emails(self, test):
response = test.admin_client.post(url, data, format="json")

# Asserts that the user was not created
assert (
response.status_code == status.HTTP_400_BAD_REQUEST
), "users can be created with an already used email"
assert response.json() == {
"email": ["user with this email already exists."]
}, "users can be created with an already used email"
assert response.status_code == status.HTTP_400_BAD_REQUEST, (
"users can be created with an already used email"
)
assert response.json() == {"email": ["user with this email already exists."]}, (
"users can be created with an already used email"
)

def test_invalid_emails(self, test):
"""test to create users with the API with authentication and invalid emails"""
Expand All @@ -182,9 +182,9 @@ def test_invalid_emails(self, test):
response = test.admin_client.post(url, data, format="json")

# Asserts that the user was not created
assert (
response.status_code == status.HTTP_400_BAD_REQUEST
), f"users can be created with an invalid email ({email})"
assert response.json() == {
"email": ["Enter a valid email address."]
}, f"users can be created with an invalid email ({email})"
assert response.status_code == status.HTTP_400_BAD_REQUEST, (
f"users can be created with an invalid email ({email})"
)
assert response.json() == {"email": ["Enter a valid email address."]}, (
f"users can be created with an invalid email ({email})"
)
Loading

0 comments on commit 8652818

Please sign in to comment.