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