7
7
from tests .integration .conftest import TEST_SINGLETON
8
8
from tests .integration .utils import INTEGRATION_TEST_COMPASS_ROOT_RID , INTEGRATION_TEST_EGRESS_POLICY_RID , MARKING_ID
9
9
10
+ SNOWFLAKE_TEST_ACCOUNT_IDENTIFIER = "fdt-integration-test-account1"
11
+
10
12
11
13
@pytest .fixture ()
12
14
def empty_s3_source () -> api_types .SourceRid :
@@ -20,7 +22,26 @@ def empty_s3_source() -> api_types.SourceRid:
20
22
21
23
yield source_rid
22
24
23
- # Delete test folder
25
+ # Delete test source
26
+ response = TEST_SINGLETON .ctx .compass .api_delete_permanently (
27
+ rids = {source_rid }, delete_options = {"DO_NOT_REQUIRE_TRASHED" }
28
+ )
29
+ assert response .status_code == 200
30
+
31
+
32
+ @pytest .fixture ()
33
+ def empty_snowflake_source () -> api_types .SourceRid :
34
+ # Create a new Snowflake
35
+ client = TEST_SINGLETON .ctx .magritte_coordinator
36
+ rnd = "" .join (choice (ascii_uppercase ) for _ in range (5 ))
37
+ name = "fdt-test-snowflake_" + rnd
38
+ source_rid = client .create_snowflake_source (
39
+ name = name , parent_rid = INTEGRATION_TEST_COMPASS_ROOT_RID , account_identifier = SNOWFLAKE_TEST_ACCOUNT_IDENTIFIER
40
+ )
41
+
42
+ yield source_rid
43
+
44
+ # Delete test source
24
45
response = TEST_SINGLETON .ctx .compass .api_delete_permanently (
25
46
rids = {source_rid }, delete_options = {"DO_NOT_REQUIRE_TRASHED" }
26
47
)
@@ -208,15 +229,9 @@ def test_export_toggles(empty_s3_source):
208
229
}
209
230
210
231
211
- def test_snowflake ():
232
+ def test_snowflake (empty_snowflake_source ):
212
233
client = TEST_SINGLETON .ctx .magritte_coordinator
213
- # Create a new S3 Direct source
214
- rnd = "" .join (choice (ascii_uppercase ) for _ in range (5 ))
215
- name = "fdt-test-snowflake_" + rnd
216
- account_identifier = "account1"
217
- source_rid = client .create_snowflake_source (
218
- name = name , parent_rid = INTEGRATION_TEST_COMPASS_ROOT_RID , account_identifier = account_identifier
219
- )
234
+ source_rid = empty_snowflake_source
220
235
221
236
# enable OIDC
222
237
client .enable_snowflake_external_oauth (source_rid = source_rid )
@@ -234,7 +249,7 @@ def test_snowflake():
234
249
oidc_issuer = client .get_oidc_issuer ()
235
250
assert as_json ["type" ] == "cloud"
236
251
assert as_json ["cloud" ]["oidcRuntime" ] == {
237
- "audience" : f"https://{ account_identifier } .snowflakecomputing.com" ,
252
+ "audience" : f"https://{ SNOWFLAKE_TEST_ACCOUNT_IDENTIFIER } .snowflakecomputing.com" ,
238
253
"issuer" : oidc_issuer ,
239
254
"subject" : source_rid ,
240
255
}
@@ -255,3 +270,41 @@ def test_snowflake():
255
270
}
256
271
257
272
TEST_SINGLETON .ctx .compass .api_delete_permanently (rids = {source_rid }, delete_options = {"DO_NOT_REQUIRE_TRASHED" })
273
+
274
+
275
+ def test_snowflake_tables (empty_snowflake_source ):
276
+ client = TEST_SINGLETON .ctx .magritte_coordinator
277
+ source_rid = empty_snowflake_source
278
+
279
+ client .enable_snowflake_external_oauth (source_rid = source_rid )
280
+
281
+ tables_client = TEST_SINGLETON .ctx .tables
282
+
283
+ tables = tables_client .list_tables (connection_rid = source_rid )
284
+ assert tables == []
285
+
286
+ table1 = tables_client .create_snowflake_table (
287
+ parent_rid = INTEGRATION_TEST_COMPASS_ROOT_RID ,
288
+ connection_rid = source_rid ,
289
+ name = "fdt-test-snowflake_table" + "" .join (choice (ascii_uppercase ) for _ in range (5 )),
290
+ database = "test" ,
291
+ schema = "test" ,
292
+ table = "test1" ,
293
+ skip_validation = True ,
294
+ )
295
+
296
+ table2 = tables_client .create_snowflake_table (
297
+ parent_rid = INTEGRATION_TEST_COMPASS_ROOT_RID ,
298
+ connection_rid = source_rid ,
299
+ name = "fdt-test-snowflake_table" + "" .join (choice (ascii_uppercase ) for _ in range (5 )),
300
+ database = "test" ,
301
+ schema = "test" ,
302
+ table = "test2" ,
303
+ skip_validation = True ,
304
+ )
305
+
306
+ tables = tables_client .list_tables (connection_rid = source_rid )
307
+ assert len (tables ) == 2
308
+
309
+ TEST_SINGLETON .ctx .compass .api_delete_permanently (rids = {table1 , table2 }, delete_options = {"DO_NOT_REQUIRE_TRASHED" })
310
+ TEST_SINGLETON .ctx .compass .api_delete_permanently (rids = {source_rid }, delete_options = {"DO_NOT_REQUIRE_TRASHED" })
0 commit comments