1
1
from collections import namedtuple
2
2
from enum import Enum
3
3
from datetime import datetime
4
+ from labelbox .orm .db_object import experimental
4
5
from random import randint
5
6
from string import ascii_letters
6
7
from types import SimpleNamespace
@@ -50,29 +51,15 @@ def testing_api_key(environ: str) -> str:
50
51
return os .environ ["LABELBOX_TEST_API_KEY_STAGING" ]
51
52
52
53
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
66
54
def cancel_invite (client , invite_id ):
67
55
"""
68
56
Do not use. Only for testing.
69
57
"""
70
58
query_str = """mutation CancelInvitePyApi($where: WhereUniqueIdInput!) {
71
59
cancelInvite(where: $where) {id}}"""
72
- client .execute (query_str , {'where' : {'id' : invite_id }})
60
+ client .execute (query_str , {'where' : {'id' : invite_id }}, experimental = True )
73
61
74
62
75
- @experimental_endpoint
76
63
def get_project_invites (client , project_id ):
77
64
"""
78
65
Do not use. Only for testing.
@@ -83,15 +70,14 @@ def get_project_invites(client, project_id):
83
70
invites(from: $from, first: $first) { nodes { %s
84
71
projectInvites { projectId projectRoleName } } nextCursor}}}
85
72
""" % (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 )
92
79
93
80
94
- @experimental_endpoint
95
81
def get_invites (client ):
96
82
"""
97
83
Do not use. Only for testing.
@@ -103,9 +89,9 @@ def get_invites(client):
103
89
client ,
104
90
query_str , {}, ['organization' , 'invites' , 'nodes' ],
105
91
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
109
95
110
96
111
97
@pytest .fixture
@@ -199,6 +185,10 @@ def sample_video() -> str:
199
185
def organization (client ):
200
186
# Must have at least one seat open in your org to run these tests
201
187
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 )
202
192
yield org
203
193
for invite in get_invites (client ):
204
194
if "@labelbox.com" in invite .email :
0 commit comments