Skip to content

Commit f587bd9

Browse files
committed
consolidate register_table tests in test_catalog
1 parent 3a9eab3 commit f587bd9

File tree

2 files changed

+45
-88
lines changed

2 files changed

+45
-88
lines changed

tests/integration/test_catalog.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,48 @@ def test_update_namespace_properties(test_catalog: Catalog, database_name: str)
355355
else:
356356
assert k in update_report.removed
357357
assert "updated test description" == test_catalog.load_namespace_properties(database_name)["comment"]
358+
359+
360+
@pytest.mark.integration
361+
@pytest.mark.parametrize("test_catalog", CATALOGS)
362+
def test_register_table(
363+
test_catalog: Catalog,
364+
table_name: str,
365+
database_name: str
366+
) -> None:
367+
identifier = (database_name, table_name)
368+
369+
test_catalog.create_namespace_if_not_exists(database_name)
370+
371+
table = test_catalog.create_table(
372+
identifier=identifier,
373+
schema=Schema(),
374+
)
375+
376+
assert test_catalog.table_exists(identifier)
377+
test_catalog.drop_table(identifier)
378+
assert not test_catalog.table_exists(identifier)
379+
test_catalog.register_table((database_name, "register_table"), metadata_location=table.metadata_location)
380+
assert test_catalog.table_exists((database_name, "register_table"))
381+
382+
383+
@pytest.mark.integration
384+
@pytest.mark.parametrize("test_catalog", CATALOGS)
385+
def test_register_table_existing(
386+
test_catalog: Catalog,
387+
table_name: str,
388+
database_name: str
389+
) -> None:
390+
identifier = (database_name, table_name)
391+
392+
test_catalog.create_namespace_if_not_exists(database_name)
393+
394+
table = test_catalog.create_table(
395+
identifier=identifier,
396+
schema=Schema(),
397+
)
398+
399+
assert test_catalog.table_exists(identifier)
400+
# Assert that registering the table again raises TableAlreadyExistsError
401+
with pytest.raises(TableAlreadyExistsError):
402+
test_catalog.register_table(identifier, metadata_location=table.metadata_location)

tests/integration/test_register_table.py

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)