66)
77from labelbox .schema .user_group import UserGroup , UserGroupColor
88
9+ from libs .labelbox .tests .conftest import AdminClient
10+ import os
11+
912data = faker .Faker ()
1013
1114
@@ -28,18 +31,18 @@ def user_group(client):
2831
2932
3033@pytest .fixture (scope = "module" )
31- def test_member (client , current_member , user_group ):
34+ def test_member (client , current_member , admin_client : AdminClient ):
35+ admin_client ._create_user (client .get_organization ().uid )
3236 members = list (Member (client = client ).get_members ())
3337 test_member = None
3438 for member in members :
3539 if member .id != current_member .id :
3640 test_member = member
37- test_member .user_group_ids .add (user_group .id )
38- updated_member = test_member .update ()
39- yield updated_member
40- # remove from any user_groups as clean up
41- updated_member .user_group_ids = set ()
42- updated_member .update ()
41+ if test_member is None :
42+ raise ValueError ("Valid member was not found" )
43+ yield test_member
44+ # delete member for clean up
45+ test_member .delete ()
4346
4447
4548def test_get_member (current_member , client ):
@@ -48,11 +51,12 @@ def test_get_member(current_member, client):
4851 assert current_member_eq .email == current_member .email
4952
5053
51- def test_throw_error_when_deleting_self (current_member , client ):
54+ def test_throw_error_when_deleting_self (current_member ):
5255 with pytest .raises (ValueError ):
5356 current_member .delete ()
5457
5558
59+ @pytest .mark .skipif (condition = os .environ ["LABELBOX_TEST_ENVIRON" ] != "staging" )
5660def test_update_member (client , test_member , project_pack , user_group ):
5761 labeler_role = client .get_roles ()["LABELER" ]
5862 reviewer_role = client .get_roles ()["REVIEWER" ]
@@ -99,6 +103,7 @@ def test_update_member(client, test_member, project_pack, user_group):
99103 assert updated_member .can_access_all_projects
100104
101105
106+ @pytest .mark .skipif (condition = os .environ ["LABELBOX_TEST_ENVIRON" ] != "staging" )
102107def test_get_members (test_member , current_member , client ):
103108 member_ids = [
104109 member .id
@@ -115,6 +120,17 @@ def test_get_members(test_member, current_member, client):
115120 assert current_member .id in member_ids
116121
117122
123+ @pytest .mark .skipif (condition = os .environ ["LABELBOX_TEST_ENVIRON" ] != "staging" )
124+ def test_delete_member (test_member , current_member , client ):
125+ email = test_member .email
126+ id = test_member .id
127+ test_member .delete ()
128+ member_ids = [
129+ member .id for member in Member (client = client ).get_members (search = email )
130+ ]
131+ assert id not in member_ids
132+
133+
118134if __name__ == "__main__" :
119135 import subprocess
120136
0 commit comments