@@ -1322,7 +1322,7 @@ class TestTeamMemberAssignmentsAPIView(ViewTestMixin):
13221322 Response fields per item: is_superadmin, role, org, scope, permission_count
13231323
13241324 Superadmin entry:
1325- admin_1..3 are staff/superusers. Querying any of them always prepends one
1325+ admin_1..3 are staff/superusers. Querying any of them adds one entry
13261326 SuperAdminAssignmentData entry: role="django.superuser" (or "django.staff"),
13271327 org="*", scope="*", permission_count=None, is_superadmin=True.
13281328 This entry is always included regardless of org/role filters, since those
@@ -1505,21 +1505,21 @@ def test_filter_by_multiple_roles(self):
15051505 )
15061506 @unpack
15071507 def test_sorting (self , sort_by : str , order : str ):
1508- """Results can be sorted by role, org, or scope in asc/desc order.
1508+ """Results are sorted by role, org, or scope in asc/desc order.
15091509
1510- Uses regular_3 and regular_4 who both have library_user in Org2:LIB2,
1511- and admin_2 who also has library_user in Org2:LIB2 — but we need a user
1512- with multiple assignments to verify ordering. Use admin_1 (staff) viewing
1513- regular_5 who has a single assignment; sorting still returns 200 OK .
1510+ Uses admin_3, who has 2 items in the response: a superadmin entry
1511+ (role="django.superuser", org="*", scope="*") and a role assignment
1512+ (role="library_admin", org="Org3", scope="lib:Org3:LIB3"). With two
1513+ distinct values per field the sort order is non-trivial and verifiable .
15141514
15151515 Expected result:
15161516 - Returns 200 OK.
15171517 - Results are ordered according to the requested field and direction.
15181518 """
1519- # admin_1 is staff so sees all assignments; regular_5 has 1 assignment
1520- response = self .client .get (self ._url ("regular_5" ), {"sort_by" : sort_by , "order" : order })
1519+ response = self .client .get (self ._url ("admin_3" ), {"sort_by" : sort_by , "order" : order })
15211520
15221521 self .assertEqual (response .status_code , status .HTTP_200_OK )
1522+ self .assertGreater (len (response .data ["results" ]), 1 )
15231523 values = [item [sort_by ] for item in response .data ["results" ]]
15241524 expected = sorted (values , key = lambda v : (v or "" ).lower (), reverse = order == "desc" )
15251525 self .assertEqual (values , expected )
0 commit comments