11from collections import namedtuple
22from enum import Enum
33from datetime import datetime
4+ from labelbox .orm .db_object import experimental
45from random import randint
56from string import ascii_letters
67from types import SimpleNamespace
@@ -50,29 +51,15 @@ def testing_api_key(environ: str) -> str:
5051 return os .environ ["LABELBOX_TEST_API_KEY_STAGING" ]
5152
5253
53- def experimental_endpoint (fn ):
54-
55- def experimental (client , * args , ** kwargs ):
56- try :
57- client .endpoint = client .endpoint .replace ("/graphql" , "/_gql" )
58- return fn (client , * args , ** kwargs )
59- finally :
60- client .endpoint = client .endpoint .replace ("/_gql" , "/graphql" )
61-
62- return experimental
63-
64-
65- @experimental_endpoint
6654def cancel_invite (client , invite_id ):
6755 """
6856 Do not use. Only for testing.
6957 """
7058 query_str = """mutation CancelInvitePyApi($where: WhereUniqueIdInput!) {
7159 cancelInvite(where: $where) {id}}"""
72- client .execute (query_str , {'where' : {'id' : invite_id }})
60+ client .execute (query_str , {'where' : {'id' : invite_id }}, experimental = True )
7361
7462
75- @experimental_endpoint
7663def get_project_invites (client , project_id ):
7764 """
7865 Do not use. Only for testing.
@@ -83,15 +70,14 @@ def get_project_invites(client, project_id):
8370 invites(from: $from, first: $first) { nodes { %s
8471 projectInvites { projectId projectRoleName } } nextCursor}}}
8572 """ % (id_param , id_param , results_query_part (Invite ))
86- return list (
87- PaginatedCollection ( client ,
88- query_str , { id_param : project_id } ,
89- [ 'project' , 'invites' , 'nodes' ] ,
90- Invite ,
91- cursor_path = [ 'project' , 'invites' , 'nextCursor' ]) )
73+ return PaginatedCollection ( client ,
74+ query_str , { id_param : project_id } ,
75+ [ 'project' , 'invites' , 'nodes' ] ,
76+ Invite ,
77+ cursor_path = [ 'project' , 'invites' , 'nextCursor' ] ,
78+ experimental = True )
9279
9380
94- @experimental_endpoint
9581def get_invites (client ):
9682 """
9783 Do not use. Only for testing.
@@ -103,9 +89,9 @@ def get_invites(client):
10389 client ,
10490 query_str , {}, ['organization' , 'invites' , 'nodes' ],
10591 Invite ,
106- cursor_path = ['organization' , 'invites' , 'nextCursor' ])
107- return list (
108- invites ) # list() so that it makes the request to the right endpoint.
92+ cursor_path = ['organization' , 'invites' , 'nextCursor' ],
93+ experimental = True )
94+ return invites
10995
11096
11197@pytest .fixture
@@ -199,6 +185,10 @@ def sample_video() -> str:
199185def organization (client ):
200186 # Must have at least one seat open in your org to run these tests
201187 org = client .get_organization ()
188+ # Clean up before and after incase this wasn't run for some reason.
189+ for invite in get_invites (client ):
190+ if "@labelbox.com" in invite .email :
191+ cancel_invite (client , invite .uid )
202192 yield org
203193 for invite in get_invites (client ):
204194 if "@labelbox.com" in invite .email :
0 commit comments