This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new b7f4e94f Consolidate `register_table` tests in `test_catalog.py` 
(#2595)
b7f4e94f is described below

commit b7f4e94ffeec990aaac500bc0a04aa14de971af7
Author: Gabriel Igliozzi <[email protected]>
AuthorDate: Sun Oct 12 17:07:07 2025 -0400

    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.
    -->
---
 tests/integration/test_catalog.py        | 37 ++++++++++++++
 tests/integration/test_register_table.py | 88 --------------------------------
 2 files changed, 37 insertions(+), 88 deletions(-)

diff --git a/tests/integration/test_catalog.py 
b/tests/integration/test_catalog.py
index b7d2cefa..db4679bc 100644
--- a/tests/integration/test_catalog.py
+++ b/tests/integration/test_catalog.py
@@ -501,3 +501,40 @@ def test_update_namespace_properties(test_catalog: 
Catalog, database_name: str)
         else:
             assert k in update_report.removed
     assert "updated test description" == 
test_catalog.load_namespace_properties(database_name)["comment"]
+
+
[email protected]
[email protected]("test_catalog", CATALOGS)
+def test_register_table(test_catalog: Catalog, table_schema_nested: Schema, 
table_name: str, database_name: str) -> None:
+    identifier = (database_name, table_name)
+
+    test_catalog.create_namespace_if_not_exists(database_name)
+
+    table = test_catalog.create_table(
+        identifier=identifier,
+        schema=table_schema_nested,
+    )
+
+    assert test_catalog.table_exists(identifier)
+    test_catalog.drop_table(identifier)
+    assert not test_catalog.table_exists(identifier)
+    test_catalog.register_table((database_name, "register_table"), 
metadata_location=table.metadata_location)
+    assert test_catalog.table_exists((database_name, "register_table"))
+
+
[email protected]
[email protected]("test_catalog", CATALOGS)
+def test_register_table_existing(test_catalog: Catalog, table_schema_nested: 
Schema, table_name: str, database_name: str) -> None:
+    identifier = (database_name, table_name)
+
+    test_catalog.create_namespace_if_not_exists(database_name)
+
+    table = test_catalog.create_table(
+        identifier=identifier,
+        schema=table_schema_nested,
+    )
+
+    assert test_catalog.table_exists(identifier)
+    # Assert that registering the table again raises TableAlreadyExistsError
+    with pytest.raises(TableAlreadyExistsError):
+        test_catalog.register_table(identifier, 
metadata_location=table.metadata_location)
diff --git a/tests/integration/test_register_table.py 
b/tests/integration/test_register_table.py
deleted file mode 100644
index c0db2014..00000000
--- a/tests/integration/test_register_table.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-import pytest
-
-from pyiceberg.catalog import Catalog
-from pyiceberg.exceptions import NoSuchTableError, TableAlreadyExistsError
-from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec
-from pyiceberg.schema import Schema
-from pyiceberg.table import Table
-from pyiceberg.types import (
-    BooleanType,
-    DateType,
-    IntegerType,
-    NestedField,
-    StringType,
-)
-
-TABLE_SCHEMA = Schema(
-    NestedField(field_id=1, name="foo", field_type=BooleanType(), 
required=False),
-    NestedField(field_id=2, name="bar", field_type=StringType(), 
required=False),
-    NestedField(field_id=4, name="baz", field_type=IntegerType(), 
required=False),
-    NestedField(field_id=10, name="qux", field_type=DateType(), 
required=False),
-)
-
-
-def _create_table(
-    session_catalog: Catalog,
-    identifier: str,
-    format_version: int,
-    location: str,
-    partition_spec: PartitionSpec = UNPARTITIONED_PARTITION_SPEC,
-    schema: Schema = TABLE_SCHEMA,
-) -> Table:
-    try:
-        session_catalog.drop_table(identifier=identifier)
-    except NoSuchTableError:
-        pass
-
-    return session_catalog.create_table(
-        identifier=identifier,
-        schema=schema,
-        location=location,
-        properties={"format-version": str(format_version)},
-        partition_spec=partition_spec,
-    )
-
-
[email protected]
[email protected]("catalog", 
[pytest.lazy_fixture("session_catalog_hive"), 
pytest.lazy_fixture("session_catalog")])
-def test_register_table(
-    catalog: Catalog,
-) -> None:
-    identifier = "default.register_table"
-    location = "s3a://warehouse/default/register_table"
-    tbl = _create_table(catalog, identifier, 2, location)
-    assert catalog.table_exists(identifier=identifier)
-    catalog.drop_table(identifier=identifier)
-    assert not catalog.table_exists(identifier=identifier)
-    catalog.register_table(("default", "register_table"), 
metadata_location=tbl.metadata_location)
-    assert catalog.table_exists(identifier=identifier)
-
-
[email protected]
[email protected]("catalog", 
[pytest.lazy_fixture("session_catalog_hive"), 
pytest.lazy_fixture("session_catalog")])
-def test_register_table_existing(
-    catalog: Catalog,
-) -> None:
-    identifier = "default.register_table_existing"
-    location = "s3a://warehouse/default/register_table_existing"
-    tbl = _create_table(catalog, identifier, 2, location)
-    assert catalog.table_exists(identifier=identifier)
-    # Assert that registering the table again raises TableAlreadyExistsError
-    with pytest.raises(TableAlreadyExistsError):
-        catalog.register_table(("default", "register_table_existing"), 
metadata_location=tbl.metadata_location)

Reply via email to