Skip to content

Commit fe2dea1

Browse files
Add MemberRole and ArchivistRole tests
1 parent 3007aff commit fe2dea1

File tree

1 file changed

+47
-33
lines changed

1 file changed

+47
-33
lines changed

tests/test_exceptions.py

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
from typed_classproperties import classproperty
77

88
from exceptions import (
9+
ArchivistRoleDoesNotExistError,
910
ChannelDoesNotExistError,
1011
CommitteeRoleDoesNotExistError,
1112
DiscordMemberNotInMainGuildError,
1213
GuestRoleDoesNotExistError,
1314
GuildDoesNotExistError,
1415
ImproperlyConfiguredError,
1516
InvalidMessagesJSONFileError,
17+
MemberRoleDoesNotExistError,
1618
MessagesJSONFileMissingKeyError,
1719
MessagesJSONFileValueError,
1820
RoleDoesNotExistError,
@@ -731,13 +733,7 @@ def test_default_dependant_message(self) -> None:
731733

732734

733735
class TestCommitteeRoleDoesNotExistError:
734-
"""
735-
Test case to unit-test the `CommitteeRoleDoesNotExistError` exception.
736-
737-
If there are no unit-tests within this test case,
738-
it is because all the functionality of `CommitteeRoleDoesNotExistError` is inherited
739-
from its parent class so is already unit-tested in the parent class's dedicated test case.
740-
"""
736+
"""Test case to unit-test the `CommitteeRoleDoesNotExistError` exception."""
741737

742738
def test_committee_role_does_not_exist_error_code(self) -> None:
743739
"""Test that the error code is set correctly."""
@@ -771,13 +767,7 @@ def test_committee_role_does_not_exist_dependent_commands(self) -> None:
771767

772768

773769
class TestGuestRoleDoesNotExistError:
774-
"""
775-
Test case to unit-test the `GuestRoleDoesNotExistError` exception.
776-
777-
If there are no unit-tests within this test case,
778-
it is because all the functionality of `GuestRoleDoesNotExistError` is inherited
779-
from its parent class so is already unit-tested in the parent class's dedicated test case.
780-
"""
770+
"""Test case to unit-test the `GuestRoleDoesNotExistError` exception."""
781771

782772
def test_guest_role_does_not_exist_error_code(self) -> None:
783773
"""Test that the error code is set correctly."""
@@ -793,35 +783,59 @@ def test_guest_role_does_not_exist_error_default_message(self) -> None:
793783
def test_guest_role_does_not_exist_dependent_commands(self) -> None:
794784
"""Test that the dependent commands are set correctly."""
795785
assert (
796-
frozenset({
797-
"induct",
798-
"stats",
799-
"archive",
800-
"ensure-members-inducted",
801-
"increment-year-channels",
802-
})
786+
frozenset(
787+
{
788+
"induct",
789+
"stats",
790+
"archive",
791+
"ensure-members-inducted",
792+
"increment-year-channels",
793+
}
794+
)
803795
== GuestRoleDoesNotExistError.DEPENDENT_COMMANDS
804796
)
805797

806798

807799
class TestMemberRoleDoesNotExistError:
808-
"""
809-
Test case to unit-test the `MemberRoleDoesNotExistError` exception.
800+
"""Test case to unit-test the `MemberRoleDoesNotExistError` exception."""
810801

811-
If there are no unit-tests within this test case,
812-
it is because all the functionality of `MemberRoleDoesNotExistError` is inherited
813-
from its parent class so is already unit-tested in the parent class's dedicated test case.
814-
"""
802+
def test_member_role_does_not_exist_error_code(self) -> None:
803+
"""Test that the error code is set correctly."""
804+
assert "E1023" in (MemberRoleDoesNotExistError().ERROR_CODE)
805+
806+
def test_member_role_does_not_exist_error_default_message(self) -> None:
807+
"""Test that the default message is correct."""
808+
assert (
809+
MemberRoleDoesNotExistError.DEFAULT_MESSAGE
810+
== 'Role with name "Member" does not exist.'
811+
)
812+
813+
def test_member_role_does_not_exist_dependent_commands(self) -> None:
814+
"""Test that the dependent commands are set correctly."""
815+
assert frozenset({"makemember", "ensure-members-inducted", "annual-roles-reset"}) == (
816+
MemberRoleDoesNotExistError.DEPENDENT_COMMANDS
817+
)
815818

816819

817820
class TestArchivistRoleDoesNotExistError:
818-
"""
819-
Test case to unit-test the `ArchivistRoleDoesNotExistError` exception.
821+
"""Test case to unit-test the `ArchivistRoleDoesNotExistError` exception."""
820822

821-
If there are no unit-tests within this test case,
822-
it is because all the functionality of `ArchivistRoleDoesNotExistError` is inherited
823-
from its parent class so is already unit-tested in the parent class's dedicated test case.
824-
"""
823+
def test_archivist_role_does_not_exist_error_code(self) -> None:
824+
"""Test that the error code is set correctly."""
825+
assert "E1024" in (ArchivistRoleDoesNotExistError().ERROR_CODE)
826+
827+
def test_archivist_role_does_not_exist_error_default_message(self) -> None:
828+
"""Test that the default message is correct."""
829+
assert (
830+
ArchivistRoleDoesNotExistError.DEFAULT_MESSAGE
831+
== 'Role with name "Archivist" does not exist.'
832+
)
833+
834+
def test_archivist_role_does_not_exist_dependent_commands(self) -> None:
835+
"""Test that the dependent commands are set correctly."""
836+
assert frozenset({"archive", "increment-year-channels"}) == (
837+
ArchivistRoleDoesNotExistError.DEPENDENT_COMMANDS
838+
)
825839

826840

827841
class TestChannelDoesNotExistError:

0 commit comments

Comments
 (0)