File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -338,8 +338,7 @@ def delete(self) -> bool:
338
338
raise UnprocessableEntityError ("Failed to delete user group" )
339
339
return result ["deleteUserGroup" ]["success" ]
340
340
341
- @staticmethod
342
- def get_user_groups (client : Client ) -> Iterator ["UserGroup" ]:
341
+ def get_user_groups (self ) -> Iterator ["UserGroup" ]:
343
342
"""
344
343
Gets all user groups in Labelbox.
345
344
@@ -377,14 +376,14 @@ def get_user_groups(client: Client) -> Iterator["UserGroup"]:
377
376
"""
378
377
nextCursor = None
379
378
while True :
380
- userGroups = client .execute (
379
+ userGroups = self . client .execute (
381
380
query , {"nextCursor" : nextCursor })["userGroups" ]
382
381
if not userGroups :
383
382
return
384
383
yield
385
384
groups = userGroups ["nodes" ]
386
385
for group in groups :
387
- userGroup = UserGroup (client )
386
+ userGroup = UserGroup (self . client )
388
387
userGroup .id = group ["id" ]
389
388
userGroup .name = group ["name" ]
390
389
userGroup .color = UserGroupColor (group ["color" ])
Original file line number Diff line number Diff line change @@ -50,15 +50,15 @@ def test_update_user_group(user_group):
50
50
51
51
def test_get_user_groups (user_group , client ):
52
52
# Get all user groups
53
- user_groups_old = list (UserGroup .get_user_groups (client ))
53
+ user_groups_old = list (UserGroup ( client ) .get_user_groups ())
54
54
55
55
# manual delete for iterators
56
56
group_name = data .name ()
57
57
user_group = UserGroup (client )
58
58
user_group .name = group_name
59
59
user_group .create ()
60
60
61
- user_groups_new = list (UserGroup .get_user_groups (client ))
61
+ user_groups_new = list (UserGroup ( client ) .get_user_groups ())
62
62
63
63
# Verify that at least one user group is returned
64
64
assert len (user_groups_new ) > 0
Original file line number Diff line number Diff line change @@ -283,7 +283,7 @@ def test_delete(self):
283
283
def test_user_groups_empty (self ):
284
284
self .client .execute .return_value = {"userGroups" : None }
285
285
286
- user_groups = list (UserGroup . get_user_groups (self .client ))
286
+ user_groups = list (UserGroup (self .client ). get_user_groups ( ))
287
287
288
288
assert len (user_groups ) == 0
289
289
@@ -362,8 +362,10 @@ def test_user_groups(self):
362
362
}
363
363
}
364
364
365
- user_groups = list (UserGroup .get_user_groups (self .client ))
365
+ user_groups = list (UserGroup (self .client ).get_user_groups ())
366
+ execute = self .client .execute .call_args [0 ]
366
367
368
+ assert "GetUserGroupsPyApi" in execute [0 ]
367
369
assert len (user_groups ) == 3
368
370
369
371
# Check the attributes of the first user group
You can’t perform that action at this time.
0 commit comments