Skip to content

Commit

Permalink
fix: assert get query set
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Feb 2, 2024
1 parent 87c6bf5 commit 0970b89
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion codeforlife/tests/model_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def assert_get_permissions(
*args,
**kwargs,
):
"""Assert that we get the expected permissions.
"""Assert that the expected permissions are returned.
Args:
permissions: The expected permissions.
Expand All @@ -706,6 +706,25 @@ def assert_get_permissions(
actual_permissions = model_view_set.get_permissions()
self.assertListEqual(permissions, actual_permissions)

def assert_get_queryset(
self,
values: t.Collection[AnyModel],
*args,
ordered: bool = True,
**kwargs,
):
"""Assert that the expected queryset is returned.
Args:
values: The values we expect the queryset to contain.
ordered: Whether the queryset provides an implicit ordering.
"""

model_view_set = self.model_view_set_class(*args, **kwargs)
queryset = model_view_set.get_queryset()
# pylint: disable-next=no-member
self.assertQuerySetEqual(queryset, values, ordered=ordered)

def get_other_user(
self,
user: User,
Expand Down

0 comments on commit 0970b89

Please sign in to comment.