|
35 | 35 | OAUTH2_SERVER_URI, |
36 | 36 | SNAPSHOT_LOADING_MODE, |
37 | 37 | Capability, |
| 38 | + Endpoint, |
| 39 | + HttpMethod, |
38 | 40 | RestCatalog, |
39 | 41 | ) |
40 | 42 | from pyiceberg.exceptions import ( |
@@ -2351,3 +2353,28 @@ def test_table_uuid_check_on_refresh(rest_mock: Mocker, example_table_metadata_v |
2351 | 2353 | assert "Table UUID does not match" in str(exc_info.value) |
2352 | 2354 | assert f"current={original_uuid}" in str(exc_info.value) |
2353 | 2355 | 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