diff --git a/codeforlife/tests/model_view_set.py b/codeforlife/tests/model_view_set.py index 36db8841..e856b7c7 100644 --- a/codeforlife/tests/model_view_set.py +++ b/codeforlife/tests/model_view_set.py @@ -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. @@ -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,