Skip to content

Commit

Permalink
Add tests for lookup errors if empty Members|Roles|Subgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
elliot-100 committed Sep 16, 2024
1 parent 40e55db commit 93708a5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ def test_member_by_id__unmatched_id_raises_lookup_error(
my_member = my_group.member_by_id("DUMMY_ID") # act


def test_member_by_id__no_members_raises_lookup_error(
simple_group_data: DictFromJSON,
) -> None:
"""Test that LookupError is raised when there are no Members."""
# arrange
my_group = Group.model_validate(simple_group_data)
# assert
assert my_group.members == []
with pytest.raises(LookupError):
my_member = my_group.member_by_id("DUMMY_ID") # act


def test_role_by_id__happy_path(complex_group_data: DictFromJSON) -> None:
"""Test that Role is returned from a valid uid."""
# arrange
Expand All @@ -75,6 +87,18 @@ def test_role_by_id__unmatched_id_raises_lookup_error(
my_role = my_group.role_by_id("DUMMY_ID") # act


def test_role_by_id__no_roles_raises_lookup_error(
simple_group_data: DictFromJSON,
) -> None:
"""Test that LookupError is raised when there are no Roles."""
# arrange
my_group = Group.model_validate(simple_group_data)
# assert
assert my_group.roles == []
with pytest.raises(LookupError):
my_role = my_group.role_by_id("DUMMY_ID") # act


def test_subgroup_by_id__happy_path(complex_group_data: DictFromJSON) -> None:
"""Test that Subgroup is returned from a valid uid."""
# arrange
Expand All @@ -96,6 +120,18 @@ def test_subgroup_by_id__unmatched_id_raises_lookup_error(
my_subgroup = my_group.subgroup_by_id("DUMMY_ID") # act


def test_subgroup_by_id__no_subgroups_raises_lookup_error(
simple_group_data: DictFromJSON,
) -> None:
"""Test that LookupError is raised when there are no Subgroups."""
# arrange
my_group = Group.model_validate(simple_group_data)
# assert
assert my_group.subgroups == []
with pytest.raises(LookupError):
my_subgroup = my_group.subgroup_by_id("DUMMY_ID") # act


def test_members_by_subgroup__happy_path(complex_group_data: DictFromJSON) -> None:
"""Test that Members are returned from a valid Subgroup."""
# arrange
Expand Down

0 comments on commit 93708a5

Please sign in to comment.