Skip to content

Commit 996e182

Browse files
kevinjqliuCopilot
andcommitted
Test REST identifiers that need URL encoding against the REST fixture
Round-trip namespace, table, and view names containing spaces, reserved URL characters, and non-ASCII text through path, query, and body parameters. This catches encoding mistakes like the double-encoded list_namespaces parent and the encoded view name in create_view. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 74f83ea commit 996e182

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

‎tests/integration/test_catalog.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,42 @@ def test_rest_drop_view(
719719
assert not rest_catalog.view_exists(identifier)
720720

721721

722+
@pytest.mark.integration
723+
def test_rest_identifiers_with_special_characters(
724+
rest_catalog: RestCatalog, table_schema_simple: Schema, example_view_metadata_v1: dict[str, Any]
725+
) -> None:
726+
"""Names that need URL encoding must round-trip unchanged through path, query, and body parameters."""
727+
# "%" is omitted because the REST fixture rejects "%25" in URL paths with a 400
728+
for name in ["with space", "a+b&c=d", "\u65e5\u672c"]:
729+
parent = (f"{name}_{uuid.uuid4().hex}",)
730+
namespace = (*parent, name)
731+
table_identifier = (*namespace, f"table {name}")
732+
view_identifier = (*namespace, f"view {name}")
733+
734+
rest_catalog.create_namespace(parent)
735+
rest_catalog.create_namespace(namespace, properties={"key": name})
736+
assert parent in rest_catalog.list_namespaces()
737+
assert rest_catalog.list_namespaces(parent) == [namespace]
738+
assert rest_catalog.namespace_exists(namespace)
739+
assert rest_catalog.load_namespace_properties(namespace)["key"] == name
740+
741+
rest_catalog.create_table(table_identifier, table_schema_simple)
742+
assert rest_catalog.table_exists(table_identifier)
743+
assert rest_catalog.list_tables(namespace) == [table_identifier]
744+
assert rest_catalog.load_table(table_identifier).name() == table_identifier
745+
746+
view = View(view_identifier, ViewMetadata.model_validate(example_view_metadata_v1))
747+
rest_catalog.create_view(view_identifier, view.schema(), view.current_version())
748+
assert rest_catalog.view_exists(view_identifier)
749+
assert rest_catalog.list_views(namespace) == [view_identifier]
750+
751+
rest_catalog.drop_view(view_identifier)
752+
rest_catalog.drop_table(table_identifier)
753+
rest_catalog.drop_namespace(namespace)
754+
rest_catalog.drop_namespace(parent)
755+
assert not rest_catalog.namespace_exists(parent)
756+
757+
722758
@pytest.mark.integration
723759
def test_rest_custom_namespace_separator(rest_catalog: RestCatalog, table_schema_simple: Schema) -> None:
724760
"""

0 commit comments

Comments
 (0)