2
2
3
3
import requests
4
4
import pytest
5
+ import uuid
5
6
6
7
from labelbox import Client
7
8
@@ -77,3 +78,114 @@ def test_no_default_integration(client):
77
78
ds = client .create_dataset (name = "new_ds" )
78
79
assert ds .iam_integration () is None
79
80
ds .delete ()
81
+
82
+
83
+ @pytest .mark .skip (
84
+ reason =
85
+ "Google credentials are being updated for this test, disabling till it's all sorted out"
86
+ )
87
+ @pytest .mark .skipif (not os .environ .get ("DA_GCP_LABELBOX_API_KEY" ),
88
+ reason = "DA_GCP_LABELBOX_API_KEY not found" )
89
+ def test_add_integration_from_object ():
90
+ """
91
+ This test is based on test_non_default_integration() and assumes the following:
92
+
93
+ 1. aws delegated access is configured to work with lbox-test-bucket
94
+ 2. an integration called aws is available to the org
95
+
96
+ Currently tests against:
97
+ Org ID: cl26d06tk0gch10901m7jeg9v
98
+ Email: jtso+aws_sdk_tests@labelbox.com
99
+ """
100
+ client = Client (api_key = os .environ .get ("DA_GCP_LABELBOX_API_KEY" ))
101
+ integrations = client .get_organization ().get_iam_integrations ()
102
+
103
+ # Prepare dataset with no integration
104
+ integration = [
105
+ integration for integration
106
+ in integrations
107
+ if 'aws-da-test-bucket' in integration .name ][0 ]
108
+
109
+ ds = client .create_dataset (iam_integration = None , name = f"integration_add_obj-{ uuid .uuid4 ()} " )
110
+
111
+ # Test set integration with object
112
+ new_integration = ds .add_iam_integration (integration )
113
+ assert new_integration == integration
114
+
115
+ # Cleaning
116
+ ds .delete ()
117
+
118
+ @pytest .mark .skip (
119
+ reason =
120
+ "Google credentials are being updated for this test, disabling till it's all sorted out"
121
+ )
122
+ @pytest .mark .skipif (not os .environ .get ("DA_GCP_LABELBOX_API_KEY" ),
123
+ reason = "DA_GCP_LABELBOX_API_KEY not found" )
124
+ def test_add_integration_from_uid ():
125
+ """
126
+ This test is based on test_non_default_integration() and assumes the following:
127
+
128
+ 1. aws delegated access is configured to work with lbox-test-bucket
129
+ 2. an integration called aws is available to the org
130
+
131
+ Currently tests against:
132
+ Org ID: cl26d06tk0gch10901m7jeg9v
133
+ Email: jtso+aws_sdk_tests@labelbox.com
134
+ """
135
+ client = Client (api_key = os .environ .get ("DA_GCP_LABELBOX_API_KEY" ))
136
+ integrations = client .get_organization ().get_iam_integrations ()
137
+
138
+ # Prepare dataset with no integration
139
+ integration = [
140
+ integration for integration
141
+ in integrations
142
+ if 'aws-da-test-bucket' in integration .name ][0 ]
143
+
144
+ ds = client .create_dataset (iam_integration = None , name = f"integration_add_id-{ uuid .uuid4 ()} " )
145
+
146
+ # Test set integration with integration id
147
+ integration_id = [
148
+ integration .uid for integration
149
+ in integrations
150
+ if 'aws-da-test-bucket' in integration .name ][0 ]
151
+
152
+ new_integration = ds .add_iam_integration (integration_id )
153
+ assert new_integration == integration
154
+
155
+ # Cleaning
156
+ ds .delete ()
157
+
158
+ @pytest .mark .skip (
159
+ reason =
160
+ "Google credentials are being updated for this test, disabling till it's all sorted out"
161
+ )
162
+ @pytest .mark .skipif (not os .environ .get ("DA_GCP_LABELBOX_API_KEY" ),
163
+ reason = "DA_GCP_LABELBOX_API_KEY not found" )
164
+ def test_integration_remove ():
165
+ """
166
+ This test is based on test_non_default_integration() and assumes the following:
167
+
168
+ 1. aws delegated access is configured to work with lbox-test-bucket
169
+ 2. an integration called aws is available to the org
170
+
171
+ Currently tests against:
172
+ Org ID: cl26d06tk0gch10901m7jeg9v
173
+ Email: jtso+aws_sdk_tests@labelbox.com
174
+ """
175
+ client = Client (api_key = os .environ .get ("DA_GCP_LABELBOX_API_KEY" ))
176
+ integrations = client .get_organization ().get_iam_integrations ()
177
+
178
+ # Prepare dataset with an existing integration
179
+ integration = [
180
+ integration for integration
181
+ in integrations
182
+ if 'aws-da-test-bucket' in integration .name ][0 ]
183
+
184
+ ds = client .create_dataset (iam_integration = integration , name = f"integration_remove-{ uuid .uuid4 ()} " )
185
+
186
+ # Test unset integration
187
+ ds .remove_iam_integration ()
188
+ assert ds .iam_integration () is None
189
+
190
+ # Cleaning
191
+ ds .delete ()
0 commit comments