Skip to content

Commit b7f4e94

Browse files
authored
Consolidate register_table tests in test_catalog.py (#2595)
<!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change These two tests are better placed in test_catalogs, so we can use custom IRCs and tests other catalogs also ## Are these changes tested? ## Are there any user-facing changes? <!-- In the case of user-facing changes, please add the changelog label. -->
1 parent 8817781 commit b7f4e94

File tree

2 files changed

+37
-88
lines changed

2 files changed

+37
-88
lines changed

tests/integration/test_catalog.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,40 @@ def test_update_namespace_properties(test_catalog: Catalog, database_name: str)
501501
else:
502502
assert k in update_report.removed
503503
assert "updated test description" == test_catalog.load_namespace_properties(database_name)["comment"]
504+
505+
506+
@pytest.mark.integration
507+
@pytest.mark.parametrize("test_catalog", CATALOGS)
508+
def test_register_table(test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str) -> None:
509+
identifier = (database_name, table_name)
510+
511+
test_catalog.create_namespace_if_not_exists(database_name)
512+
513+
table = test_catalog.create_table(
514+
identifier=identifier,
515+
schema=table_schema_nested,
516+
)
517+
518+
assert test_catalog.table_exists(identifier)
519+
test_catalog.drop_table(identifier)
520+
assert not test_catalog.table_exists(identifier)
521+
test_catalog.register_table((database_name, "register_table"), metadata_location=table.metadata_location)
522+
assert test_catalog.table_exists((database_name, "register_table"))
523+
524+
525+
@pytest.mark.integration
526+
@pytest.mark.parametrize("test_catalog", CATALOGS)
527+
def test_register_table_existing(test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str) -> None:
528+
identifier = (database_name, table_name)
529+
530+
test_catalog.create_namespace_if_not_exists(database_name)
531+
532+
table = test_catalog.create_table(
533+
identifier=identifier,
534+
schema=table_schema_nested,
535+
)
536+
537+
assert test_catalog.table_exists(identifier)
538+
# Assert that registering the table again raises TableAlreadyExistsError
539+
with pytest.raises(TableAlreadyExistsError):
540+
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)