Skip to content

Commit e613750

Browse files
committed
steal some more integration tests
1 parent 90771b9 commit e613750

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

tests/integration/test_catalog.py

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@
2020

2121
import pytest
2222

23-
from pyiceberg.catalog import Catalog
23+
from pyiceberg.catalog import Catalog, MetastoreCatalog
2424
from pyiceberg.catalog.dynamodb import DynamoDbCatalog
2525
from pyiceberg.catalog.glue import GLUE_CATALOG_ENDPOINT, GlueCatalog
2626
from pyiceberg.catalog.hive import HiveCatalog
2727
from pyiceberg.catalog.memory import InMemoryCatalog
2828
from pyiceberg.catalog.rest import RestCatalog
2929
from pyiceberg.catalog.sql import SqlCatalog
3030
from pyiceberg.io import WAREHOUSE
31+
from pyiceberg.schema import Schema
3132
from tests.conftest import clean_up, get_bucket_name, get_glue_endpoint, get_s3_path
3233

33-
# The number of tables/databases used in list_table/namespace test
34-
LIST_TEST_NUMBER = 2
35-
3634

3735
@pytest.fixture(scope="function")
3836
def dynamodb() -> Generator[Catalog, None, None]:
@@ -117,3 +115,49 @@ def test_create_namespace(
117115
test_catalog.create_namespace(database_name)
118116
# note the use of `in` because some catalogs have a "default" namespace
119117
assert (database_name,) in test_catalog.list_namespaces()
118+
119+
120+
@pytest.mark.integration
121+
@pytest.mark.parametrize(
122+
"test_catalog",
123+
[
124+
pytest.lazy_fixture("glue"),
125+
pytest.lazy_fixture("dynamodb"),
126+
pytest.lazy_fixture("memory_catalog"),
127+
pytest.lazy_fixture("sqlite_catalog_memory"),
128+
pytest.lazy_fixture("sqlite_catalog_file"),
129+
pytest.lazy_fixture("rest_catalog"),
130+
pytest.lazy_fixture("hive_catalog"),
131+
],
132+
)
133+
def test_create_table_with_default_location(
134+
test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str
135+
) -> None:
136+
identifier = (database_name, table_name)
137+
test_catalog.create_namespace(database_name)
138+
test_catalog.create_table(identifier, table_schema_nested)
139+
table = test_catalog.load_table(identifier)
140+
assert table.name() == identifier
141+
assert MetastoreCatalog._parse_metadata_version(table.metadata_location) == 0
142+
143+
144+
@pytest.mark.integration
145+
@pytest.mark.parametrize(
146+
"test_catalog",
147+
[
148+
pytest.lazy_fixture("glue"),
149+
pytest.lazy_fixture("dynamodb"),
150+
pytest.lazy_fixture("memory_catalog"),
151+
pytest.lazy_fixture("sqlite_catalog_memory"),
152+
pytest.lazy_fixture("sqlite_catalog_file"),
153+
pytest.lazy_fixture("rest_catalog"),
154+
pytest.lazy_fixture("hive_catalog"),
155+
],
156+
)
157+
def test_create_table_with_invalid_location(
158+
test_catalog: Catalog, table_schema_nested: Schema, table_name: str, database_name: str
159+
) -> None:
160+
identifier = (database_name, table_name)
161+
test_catalog.create_namespace(database_name)
162+
with pytest.raises(ValueError):
163+
test_catalog.create_table(identifier, table_schema_nested)

0 commit comments

Comments
 (0)