Skip to content

Commit

Permalink
tests: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Aug 24, 2023
1 parent 26184ef commit 273d065
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion backend/trcustoms/common/errors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
from typing import Any

from rest_framework import status
from rest_framework.exceptions import APIException


class CustomAPIException(APIException):
def __init__(self, detail: Any, code: str) -> None:
def __init__(
self,
detail: Any,
code: str,
status_code: int = status.HTTP_400_BAD_REQUEST,
) -> None:
self.status_code = status_code
self.code = code
super().__init__({**detail, "code": code})
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def test_playlist_item_creation_rejects_duplicate_submissions(

assert resp.status_code == status.HTTP_400_BAD_REQUEST, resp.content
assert resp.json() == {
"level_id": ["This level already appears in this playlist."]
"level_id": "This level already appears in this playlist.",
"code": "duplicate_level",
}
assert playlist_item_count == 1

Expand Down
2 changes: 2 additions & 0 deletions backend/trcustoms/users/tests/test_users_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_user_creation(
"bio": payload["bio"],
"date_joined": any_datetime(allow_strings=True),
"last_login": None,
"played_level_count": 0,
"authored_level_count": 0,
"authored_walkthrough_count": 0,
"reviewed_level_count": 0,
Expand Down Expand Up @@ -287,6 +288,7 @@ def test_user_creation_acquiring_trle_account(
"bio": "",
"date_joined": any_datetime(allow_strings=True),
"last_login": None,
"played_level_count": 0,
"authored_level_count": 0,
"authored_walkthrough_count": 0,
"reviewed_level_count": 0,
Expand Down

0 comments on commit 273d065

Please sign in to comment.