Skip to content

Commit 24864fe

Browse files
Fix some stuff
1 parent 343cb28 commit 24864fe

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/test_exceptions.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,18 @@ def DEPENDENT_COMMANDS(cls) -> frozenset[str]:
665665
"""
666666
return frozenset(("test_command_1",))
667667

668+
@classproperty
669+
@override
670+
def DEPENDENT_TASKS(cls) -> frozenset[str]:
671+
"""The set of names of bot tasks that require this Discord entity."""
672+
return frozenset(("test_task_1",))
673+
674+
@classproperty
675+
@override
676+
def DEPENDENT_EVENTS(cls) -> frozenset[str]:
677+
"""The set of names of bot events that require this Discord entity."""
678+
return frozenset(("test_event_1",))
679+
668680
@classproperty
669681
@override
670682
def ROLE_NAME(cls) -> str:
@@ -688,6 +700,38 @@ def test_role_name_in_str(self) -> None:
688700
self._RoleDoesNotExistErrorSubclass()
689701
)
690702

703+
def test_error_code(self) -> None:
704+
"""Test that the error code is set correctly."""
705+
assert self._RoleDoesNotExistErrorSubclass.ERROR_CODE == "E1"
706+
707+
def test_default_message(self) -> None:
708+
"""Test that the default message is correct."""
709+
assert (
710+
self._RoleDoesNotExistErrorSubclass.DEFAULT_MESSAGE == (
711+
'Role with name "role_name_1" does not exist.'
712+
)
713+
)
714+
715+
def test_init_with_custom_message(self) -> None:
716+
"""Test that a custom message is used if provided."""
717+
msg = "Custom error message"
718+
exc = self._RoleDoesNotExistErrorSubclass(msg)
719+
assert str(exc) == msg
720+
721+
def test_default_dependant_message(self) -> None:
722+
"""Test that the default message is correct."""
723+
test_exception: RoleDoesNotExistError = self._RoleDoesNotExistErrorSubclass()
724+
assert (
725+
test_exception.get_formatted_message(
726+
non_existent_object_identifier=test_exception.ROLE_NAME,
727+
)
728+
== (
729+
f'"{test_exception.ROLE_NAME}" {test_exception.DOES_NOT_EXIST_TYPE} must exist'
730+
" in order to use the \"/test_command_1\" command, the \"test_task_1\" task"
731+
" and the \"test_event_1\" event."
732+
)
733+
)
734+
691735

692736
class TestCommitteeRoleDoesNotExistError:
693737
"""

0 commit comments

Comments
 (0)