Skip to content

Commit 354f148

Browse files
Add all valid Http Methods
1 parent 8ed9012 commit 354f148

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ class HttpMethod(str, Enum):
8989
POST = "POST"
9090
DELETE = "DELETE"
9191
PUT = "PUT"
92+
CONNECT = "CONNECT"
93+
OPTIONS = "OPTIONS"
94+
TRACE = "TRACE"
95+
PATCH = "PATCH"
9296

9397

9498
class Endpoint(IcebergBaseModel):

tests/catalog/test_rest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
OAUTH2_SERVER_URI,
3636
SNAPSHOT_LOADING_MODE,
3737
Capability,
38+
Endpoint,
39+
HttpMethod,
3840
RestCatalog,
3941
)
4042
from pyiceberg.exceptions import (
@@ -2351,3 +2353,28 @@ def test_table_uuid_check_on_refresh(rest_mock: Mocker, example_table_metadata_v
23512353
assert "Table UUID does not match" in str(exc_info.value)
23522354
assert f"current={original_uuid}" in str(exc_info.value)
23532355
assert f"refreshed={different_uuid}" in str(exc_info.value)
2356+
2357+
2358+
@pytest.mark.parametrize(
2359+
"raw_string, http_method, path",
2360+
[
2361+
("GET /v1/resource", HttpMethod.GET, "/v1/resource"),
2362+
("HEAD /v1/resource", HttpMethod.HEAD, "/v1/resource"),
2363+
("POST /v1/resource", HttpMethod.POST, "/v1/resource"),
2364+
("DELETE /v1/resource", HttpMethod.DELETE, "/v1/resource"),
2365+
("PUT /v1/resource", HttpMethod.PUT, "/v1/resource"),
2366+
("CONNECT /v1/resource", HttpMethod.CONNECT, "/v1/resource"),
2367+
("OPTIONS /v1/resource", HttpMethod.OPTIONS, "/v1/resource"),
2368+
("TRACE /v1/resource", HttpMethod.TRACE, "/v1/resource"),
2369+
("PATCH /v1/resource", HttpMethod.PATCH, "/v1/resource"),
2370+
],
2371+
)
2372+
def test_endpoint_parsing_from_string_with_valid_http_method(raw_string: str, http_method: str, path: str) -> None:
2373+
endpoint = Endpoint.from_string(raw_string)
2374+
assert endpoint.http_method == http_method
2375+
assert endpoint.path == path
2376+
2377+
2378+
def test_endpoint_parsing_from_string_with_invalid_http_method() -> None:
2379+
with pytest.raises(ValueError, match="not a valid HttpMethod"):
2380+
Endpoint.from_string("INVALID /v1/resource")

0 commit comments

Comments
 (0)