@@ -341,6 +341,7 @@ def test_get_table_names_smoke_test(samples_engine: Engine):
341
341
_names = samples_engine .table_names (schema = "nyctaxi" , connection = conn )
342
342
_names is not None , "get_table_names did not succeed"
343
343
344
+
344
345
def test_has_table_across_schemas (db_engine : Engine , samples_engine : Engine ):
345
346
"""For this test to pass these conditions must be met:
346
347
- Table samples.nyctaxi.trips must exist
@@ -349,25 +350,34 @@ def test_has_table_across_schemas(db_engine: Engine, samples_engine: Engine):
349
350
"""
350
351
351
352
with samples_engine .connect () as conn :
352
-
353
- # Check for table within schema declared at engine creation time
354
- assert samples_engine .dialect .has_table (connection = conn , table_name = "trips" )
355
-
356
- # Check for table within another schema in the same catalog
357
- assert samples_engine .dialect .has_table (connection = conn , table_name = "customer" , schema = "tpch" )
358
-
359
- # Check for a table within a different catalog
360
- other_catalog = os .environ .get ("catalog" )
361
- other_schema = os .environ .get ("schema" )
362
-
363
- # Create a table in a different catalog
364
- with db_engine .connect () as conn :
365
- conn .execute ("CREATE TABLE test_has_table (numbers_are_cool INT);" )
366
-
367
- try :
368
- # Verify with a different engine that this table is not found in the samples catalog
369
- assert not samples_engine .dialect .has_table (connection = conn , table_name = "test_has_table" )
370
- # Verify with a different engine that this table is found in a separate catalog
371
- assert samples_engine .dialect .has_table (connection = conn , table_name = "test_has_table" , schema = other_schema , catalog = other_catalog )
372
- finally :
373
- conn .execute ("DROP TABLE test_has_table;" )
353
+
354
+ # 1) Check for table within schema declared at engine creation time
355
+ assert samples_engine .dialect .has_table (connection = conn , table_name = "trips" )
356
+
357
+ # 2) Check for table within another schema in the same catalog
358
+ assert samples_engine .dialect .has_table (
359
+ connection = conn , table_name = "customer" , schema = "tpch"
360
+ )
361
+
362
+ # 3) Check for a table within a different catalog
363
+ other_catalog = os .environ .get ("catalog" )
364
+ other_schema = os .environ .get ("schema" )
365
+
366
+ # Create a table in a different catalog
367
+ with db_engine .connect () as conn :
368
+ conn .execute ("CREATE TABLE test_has_table (numbers_are_cool INT);" )
369
+
370
+ try :
371
+ # Verify that this table is not found in the samples catalog
372
+ assert not samples_engine .dialect .has_table (
373
+ connection = conn , table_name = "test_has_table"
374
+ )
375
+ # Verify that this table is found in a separate catalog
376
+ assert samples_engine .dialect .has_table (
377
+ connection = conn ,
378
+ table_name = "test_has_table" ,
379
+ schema = other_schema ,
380
+ catalog = other_catalog ,
381
+ )
382
+ finally :
383
+ conn .execute ("DROP TABLE test_has_table;" )
0 commit comments