Skip to content

Commit

Permalink
TEST: adopt new rest catalog image and enable tableExists tests (apac…
Browse files Browse the repository at this point in the history
…he#1389)

* test new rest catalog image

* Point to `iceberg-rest-fixture`

* allow 200 response in table_exists

* be graceful in handling 200 response in table_exists

---------

Co-authored-by: Fokko Driesprong <fokko@apache.org>
  • Loading branch information
sungwy and Fokko authored Dec 7, 2024
1 parent e395c8e commit 6714257
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev/docker-compose-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ services:
- hive:hive
- minio:minio
rest:
image: tabulario/iceberg-rest
image: apache/iceberg-rest-fixture
container_name: pyiceberg-rest
networks:
iceberg_net:
Expand Down
2 changes: 1 addition & 1 deletion pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool:

if response.status_code == 404:
return False
elif response.status_code == 204:
elif response.status_code in (200, 204):
return True

try:
Expand Down
2 changes: 1 addition & 1 deletion tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def test_table_exists_200(rest_mock: Mocker) -> None:
request_headers=TEST_HEADERS,
)
catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
assert not catalog.table_exists(("fokko", "table"))
assert catalog.table_exists(("fokko", "table"))


def test_table_exists_204(rest_mock: Mocker) -> None:
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/test_writes/test_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,10 +1368,9 @@ def test_table_v1_with_null_nested_namespace(session_catalog: Catalog, arrow_tab
identifier = "default.lower.table_v1_with_null_nested_namespace"
tbl = _create_table(session_catalog, identifier, {"format-version": "1"}, [arrow_table_with_null])
assert tbl.format_version == 1, f"Expected v1, got: v{tbl.format_version}"
# TODO: Add session_catalog.table_exists check here when we integrate a REST catalog image
# that supports HEAD request on table endpoint

# assert session_catalog.table_exists(identifier)
assert session_catalog.load_table(identifier) is not None
assert session_catalog.table_exists(identifier)

# We expect no error here
session_catalog.drop_table(identifier)
Expand Down

0 comments on commit 6714257

Please sign in to comment.