Skip to content

Commit

Permalink
fix some api tests error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdev8 committed Feb 23, 2024
1 parent 1ba806f commit be20497
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions backend/app_tests/api/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def get_object(
# User does not have permission to view the object
assert (
response.status_code == user_perm_expected_status
), f"{verbose_name} are accessible without permission" if expected_status == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} are accessible without permission" if response.status_code == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} should give a status {user_perm_expected_status}"

if (
base_count == 0
Expand Down Expand Up @@ -376,7 +376,7 @@ def get_object(
# User does not have permission to view the object
assert (
response.status_code == user_perm_expected_status
), f"{verbose_name} are accessible without permission" if expected_status == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} are accessible without permission" if response.status_code == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} should give a status {user_perm_expected_status}"

if not (fails or user_perm_fails):
if base_count < 0:
Expand Down Expand Up @@ -444,7 +444,7 @@ def get_object_options(
# User does not have permission to view the object
assert (
response.status_code == user_perm_expected_status
), f"{verbose_name} {option} choices are accessible without permission" if expected_status == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} {option} should give a status {user_perm_expected_status}"
), f"{verbose_name} {option} choices are accessible without permission" if response.status_code == status.HTTP_200_OK else f"Accessing {verbose_name.lower()} {option} should give a status {user_perm_expected_status}"

if not (fails or user_perm_fails):
for choice in choices:
Expand Down Expand Up @@ -500,7 +500,7 @@ def create_object(
# User does not have permission to create the object
assert (
response.status_code == user_perm_expected_status
), f"{verbose_name} can be created without permission" if expected_status == status.HTTP_201_CREATED else f"Creating {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} can be created without permission" if response.status_code == status.HTTP_201_CREATED else f"Creating {verbose_name.lower()} should give a status {user_perm_expected_status}"

for key, value in build_params.items():
if key == "attachment":
Expand Down Expand Up @@ -639,7 +639,7 @@ def update_object(
# User does not have permission to update the object
assert (
update_response.status_code == user_perm_expected_status
), f"{verbose_name} can be updated without permission" if expected_status == status.HTTP_200_OK else f"Updating {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} can be updated without permission" if update_response.status_code == status.HTTP_200_OK else f"Updating {verbose_name.lower()} should give a status {user_perm_expected_status}"

if not (fails or user_perm_fails):
for key, value in {**build_params, **update_params, **test_params}.items():
Expand Down Expand Up @@ -725,7 +725,7 @@ def delete_object(
# User does not have permission to delete the object
assert (
delete_response.status_code == user_perm_expected_status
), f"{verbose_name} can be deleted without permission" if expected_status == status.HTTP_204_NO_CONTENT else f"Deleting {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} can be deleted without permission" if delete_response.status_code == status.HTTP_204_NO_CONTENT else f"Deleting {verbose_name.lower()} should give a status {user_perm_expected_status}"

if not (fails or user_perm_fails):
# Asserts that the objects does not exists anymore
Expand Down Expand Up @@ -768,7 +768,7 @@ def import_object(
# User does not have permission to import the library
assert (
response.status_code == user_perm_expected_status
), f"{verbose_name} can be imported without permission" if expected_status == status.HTTP_200_OK else f"Importing {verbose_name.lower()} should give a status {user_perm_expected_status}"
), f"{verbose_name} can be imported without permission" if response.status_code == status.HTTP_200_OK else f"Importing {verbose_name.lower()} should give a status {user_perm_expected_status}"

if not (fails or user_perm_fails):
assert response.json() == {
Expand Down

0 comments on commit be20497

Please sign in to comment.