Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyiceberg/catalog/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ class HttpMethod(str, Enum):
HEAD = "HEAD"
POST = "POST"
DELETE = "DELETE"
PUT = "PUT"
CONNECT = "CONNECT"
OPTIONS = "OPTIONS"
TRACE = "TRACE"
PATCH = "PATCH"


class Endpoint(IcebergBaseModel):
Expand Down
27 changes: 27 additions & 0 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
OAUTH2_SERVER_URI,
SNAPSHOT_LOADING_MODE,
Capability,
Endpoint,
HttpMethod,
RestCatalog,
)
from pyiceberg.exceptions import (
Expand Down Expand Up @@ -2351,3 +2353,28 @@ def test_table_uuid_check_on_refresh(rest_mock: Mocker, example_table_metadata_v
assert "Table UUID does not match" in str(exc_info.value)
assert f"current={original_uuid}" in str(exc_info.value)
assert f"refreshed={different_uuid}" in str(exc_info.value)


@pytest.mark.parametrize(
"raw_string, http_method, path",
[
("GET /v1/resource", HttpMethod.GET, "/v1/resource"),
("HEAD /v1/resource", HttpMethod.HEAD, "/v1/resource"),
("POST /v1/resource", HttpMethod.POST, "/v1/resource"),
("DELETE /v1/resource", HttpMethod.DELETE, "/v1/resource"),
("PUT /v1/resource", HttpMethod.PUT, "/v1/resource"),
("CONNECT /v1/resource", HttpMethod.CONNECT, "/v1/resource"),
("OPTIONS /v1/resource", HttpMethod.OPTIONS, "/v1/resource"),
("TRACE /v1/resource", HttpMethod.TRACE, "/v1/resource"),
("PATCH /v1/resource", HttpMethod.PATCH, "/v1/resource"),
],
)
def test_endpoint_parsing_from_string_with_valid_http_method(raw_string: str, http_method: str, path: str) -> None:
endpoint = Endpoint.from_string(raw_string)
assert endpoint.http_method == http_method
assert endpoint.path == path


def test_endpoint_parsing_from_string_with_invalid_http_method() -> None:
with pytest.raises(ValueError, match="not a valid HttpMethod"):
Endpoint.from_string("INVALID /v1/resource")