|
24 | 24 |
|
25 | 25 | import pyiceberg
|
26 | 26 | from pyiceberg.catalog import PropertiesUpdateSummary, load_catalog
|
27 |
| -from pyiceberg.catalog.rest import OAUTH2_SERVER_URI, RestCatalog |
| 27 | +from pyiceberg.catalog.rest import OAUTH2_SERVER_URI, SNAPSHOT_LOADING_MODE, RestCatalog |
28 | 28 | from pyiceberg.exceptions import (
|
29 | 29 | AuthorizationExpiredError,
|
30 | 30 | NamespaceAlreadyExistsError,
|
@@ -555,6 +555,24 @@ def test_list_namespace_with_parent_200(rest_mock: Mocker) -> None:
|
555 | 555 | ]
|
556 | 556 |
|
557 | 557 |
|
| 558 | +def test_list_namespace_with_parent_404(rest_mock: Mocker) -> None: |
| 559 | + rest_mock.get( |
| 560 | + f"{TEST_URI}v1/namespaces?parent=some_namespace", |
| 561 | + json={ |
| 562 | + "error": { |
| 563 | + "message": "Namespace provided in the `parent` query parameter is not found", |
| 564 | + "type": "NoSuchNamespaceException", |
| 565 | + "code": 404, |
| 566 | + } |
| 567 | + }, |
| 568 | + status_code=404, |
| 569 | + request_headers=TEST_HEADERS, |
| 570 | + ) |
| 571 | + |
| 572 | + with pytest.raises(NoSuchNamespaceError): |
| 573 | + RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN).list_namespaces(("some_namespace",)) |
| 574 | + |
| 575 | + |
558 | 576 | @pytest.mark.filterwarnings(
|
559 | 577 | "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
|
560 | 578 | )
|
@@ -835,6 +853,29 @@ def test_load_table_200(rest_mock: Mocker, example_table_metadata_with_snapshot_
|
835 | 853 | assert actual == expected
|
836 | 854 |
|
837 | 855 |
|
| 856 | +def test_load_table_200_loading_mode( |
| 857 | + rest_mock: Mocker, example_table_metadata_with_snapshot_v1_rest_json: Dict[str, Any] |
| 858 | +) -> None: |
| 859 | + rest_mock.get( |
| 860 | + f"{TEST_URI}v1/namespaces/fokko/tables/table?snapshots=refs", |
| 861 | + json=example_table_metadata_with_snapshot_v1_rest_json, |
| 862 | + status_code=200, |
| 863 | + request_headers=TEST_HEADERS, |
| 864 | + ) |
| 865 | + catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN, **{SNAPSHOT_LOADING_MODE: "refs"}) |
| 866 | + actual = catalog.load_table(("fokko", "table")) |
| 867 | + expected = Table( |
| 868 | + identifier=("fokko", "table"), |
| 869 | + metadata_location=example_table_metadata_with_snapshot_v1_rest_json["metadata-location"], |
| 870 | + metadata=TableMetadataV1(**example_table_metadata_with_snapshot_v1_rest_json["metadata"]), |
| 871 | + io=load_file_io(), |
| 872 | + catalog=catalog, |
| 873 | + ) |
| 874 | + # First compare the dicts |
| 875 | + assert actual.metadata.model_dump() == expected.metadata.model_dump() |
| 876 | + assert actual == expected |
| 877 | + |
| 878 | + |
838 | 879 | def test_load_table_honor_access_delegation(
|
839 | 880 | rest_mock: Mocker, example_table_metadata_with_snapshot_v1_rest_json: Dict[str, Any]
|
840 | 881 | ) -> None:
|
|
0 commit comments