11from collections import namedtuple
22from enum import Enum
33from datetime import datetime
4- from labelbox .orm .model import Entity
5- from labelbox .orm .query import Query , results_query_part
6- from labelbox .schema .invite import Invite
7- from labelbox .pagination import PaginatedCollection
8- import os
94from random import randint
10- import re
115from string import ascii_letters
6+ import os
7+ import re
128
139import pytest
1410
11+ from labelbox .orm .query import results_query_part
12+ from labelbox .schema .invite import Invite
13+ from labelbox .pagination import PaginatedCollection
1514from labelbox .schema .user import User
1615from labelbox import Client
1716
@@ -49,15 +48,19 @@ def testing_api_key(environ: str) -> str:
4948 return os .environ ["LABELBOX_TEST_API_KEY_PROD" ]
5049 return os .environ ["LABELBOX_TEST_API_KEY_STAGING" ]
5150
51+
5252def beta_endpoint (fn ):
53- def beta (client ,* args , ** kwargs ):
53+
54+ def beta (client , * args , ** kwargs ):
5455 try :
5556 client .endpoint = client .endpoint .replace ("/graphql" , "/_gql" )
56- return fn (client , * args , ** kwargs )
57+ return fn (client , * args , ** kwargs )
5758 finally :
5859 client .endpoint = client .endpoint .replace ("/_gql" , "/graphql" )
60+
5961 return beta
6062
63+
6164@beta_endpoint
6265def cancel_invite (client , invite_id ):
6366 """
@@ -67,6 +70,7 @@ def cancel_invite(client, invite_id):
6770 cancelInvite(where: $where) {id}}"""
6871 client .execute (query_str , {'where' : {'id' : invite_id }})
6972
73+
7074@beta_endpoint
7175def get_project_invites (client , project_id ):
7276 """
@@ -78,11 +82,13 @@ def get_project_invites(client, project_id):
7882 invites(from: $from, first: $first) { nodes { %s
7983 projectInvites { projectId projectRoleName } } nextCursor}}}
8084 """ % (id_param , id_param , results_query_part (Invite ))
81- return list (PaginatedCollection (
82- client ,
83- query_str , {id_param : project_id }, ['project' , 'invites' , 'nodes' ],
84- Invite ,
85- cursor_path = ['project' , 'invites' , 'nextCursor' ]))
85+ return list (
86+ PaginatedCollection (client ,
87+ query_str , {id_param : project_id },
88+ ['project' , 'invites' , 'nodes' ],
89+ Invite ,
90+ cursor_path = ['project' , 'invites' , 'nextCursor' ]))
91+
8692
8793@beta_endpoint
8894def get_invites (client ):
@@ -93,11 +99,13 @@ def get_invites(client):
9399 organization { id invites(from: $from, first: $first) {
94100 nodes { id createdAt organizationRoleName inviteeEmail } nextCursor }}}"""
95101 invites = PaginatedCollection (
96- client ,
97- query_str , {}, ['organization' , 'invites' , 'nodes' ],
98- Invite ,
99- cursor_path = ['organization' , 'invites' , 'nextCursor' ])
100- return list (invites ) # list() so that it makes the request to the right endpoint.
102+ client ,
103+ query_str , {}, ['organization' , 'invites' , 'nodes' ],
104+ Invite ,
105+ cursor_path = ['organization' , 'invites' , 'nextCursor' ])
106+ return list (
107+ invites ) # list() so that it makes the request to the right endpoint.
108+
101109
102110class IntegrationClient (Client ):
103111
@@ -188,6 +196,7 @@ def organization(client):
188196 if "@labelbox.com" in invite .email :
189197 cancel_invite (client , invite .uid )
190198
199+
191200@pytest .fixture
192201def project_based_user (client , rand_gen ):
193202 email = rand_gen (str )
@@ -211,6 +220,7 @@ def project_based_user(client, rand_gen):
211220 yield user
212221 client .get_organization ().remove_user (user )
213222
223+
214224@pytest .fixture
215225def project_pack (client ):
216226 projects = [
0 commit comments