Skip to content

Commit 6714257

Browse files
sungwyFokko
andauthored
TEST: adopt new rest catalog image and enable tableExists tests (#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 <[email protected]>
1 parent e395c8e commit 6714257

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

dev/docker-compose-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ services:
4141
- hive:hive
4242
- minio:minio
4343
rest:
44-
image: tabulario/iceberg-rest
44+
image: apache/iceberg-rest-fixture
4545
container_name: pyiceberg-rest
4646
networks:
4747
iceberg_net:

pyiceberg/catalog/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool:
887887

888888
if response.status_code == 404:
889889
return False
890-
elif response.status_code == 204:
890+
elif response.status_code in (200, 204):
891891
return True
892892

893893
try:

tests/catalog/test_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ def test_table_exists_200(rest_mock: Mocker) -> None:
801801
request_headers=TEST_HEADERS,
802802
)
803803
catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
804-
assert not catalog.table_exists(("fokko", "table"))
804+
assert catalog.table_exists(("fokko", "table"))
805805

806806

807807
def test_table_exists_204(rest_mock: Mocker) -> None:

tests/integration/test_writes/test_writes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,9 @@ def test_table_v1_with_null_nested_namespace(session_catalog: Catalog, arrow_tab
13681368
identifier = "default.lower.table_v1_with_null_nested_namespace"
13691369
tbl = _create_table(session_catalog, identifier, {"format-version": "1"}, [arrow_table_with_null])
13701370
assert tbl.format_version == 1, f"Expected v1, got: v{tbl.format_version}"
1371-
# TODO: Add session_catalog.table_exists check here when we integrate a REST catalog image
1372-
# that supports HEAD request on table endpoint
13731371

1374-
# assert session_catalog.table_exists(identifier)
1372+
assert session_catalog.load_table(identifier) is not None
1373+
assert session_catalog.table_exists(identifier)
13751374

13761375
# We expect no error here
13771376
session_catalog.drop_table(identifier)

0 commit comments

Comments
 (0)