Skip to content

Commit

Permalink
Remove deprecation warnings (apache#1416)
Browse files Browse the repository at this point in the history
* tests/expressions/test_parser.py::test_is_null
Deprecated in 0.8.0, will be removed in 0.9.0. Parsing expressions with table name is deprecated. Only provide field names in the row_filter.

* tests/catalog/test_rest.py:
Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI configuration
  • Loading branch information
kevinjqliu authored Jan 3, 2025
1 parent f863c4e commit acd6f5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 0 additions & 1 deletion pyiceberg/utils/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def deprecation_message(deprecated_in: str, removed_in: str, help_message: Optio

def _deprecation_warning(message: str) -> None:
with warnings.catch_warnings(): # temporarily override warning handling
warnings.simplefilter("always", DeprecationWarning) # turn off filter
warnings.warn(
message,
category=DeprecationWarning,
Expand Down
33 changes: 33 additions & 0 deletions tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def test_no_uri_supplied() -> None:
RestCatalog("production")


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_200(rest_mock: Mocker) -> None:
rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -141,6 +144,9 @@ def test_token_200(rest_mock: Mocker) -> None:
)


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_200_without_optional_fields(rest_mock: Mocker) -> None:
rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -157,6 +163,9 @@ def test_token_200_without_optional_fields(rest_mock: Mocker) -> None:
)


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None:
mock_request = rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -179,6 +188,9 @@ def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None:
assert TEST_RESOURCE in mock_request.last_request.text


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None:
mock_request = rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -199,6 +211,9 @@ def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None:
assert TEST_RESOURCE not in mock_request.last_request.text


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_with_default_scope(rest_mock: Mocker) -> None:
mock_request = rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -217,6 +232,9 @@ def test_token_with_default_scope(rest_mock: Mocker) -> None:
assert "catalog" in mock_request.last_request.text


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_with_custom_scope(rest_mock: Mocker) -> None:
mock_request = rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -236,6 +254,9 @@ def test_token_with_custom_scope(rest_mock: Mocker) -> None:
assert TEST_SCOPE in mock_request.last_request.text


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_200_w_auth_url(rest_mock: Mocker) -> None:
rest_mock.post(
TEST_AUTH_URL,
Expand All @@ -258,6 +279,9 @@ def test_token_200_w_auth_url(rest_mock: Mocker) -> None:
# pylint: enable=W0212


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_config_200(requests_mock: Mocker) -> None:
requests_mock.get(
f"{TEST_URI}v1/config",
Expand Down Expand Up @@ -343,6 +367,9 @@ def test_config_sets_headers(requests_mock: Mocker) -> None:
)


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_400(rest_mock: Mocker) -> None:
rest_mock.post(
f"{TEST_URI}v1/oauth/tokens",
Expand All @@ -356,6 +383,9 @@ def test_token_400(rest_mock: Mocker) -> None:
assert str(e.value) == "invalid_client: Credentials for key invalid_key do not match"


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_token_401(rest_mock: Mocker) -> None:
message = "invalid_client"
rest_mock.post(
Expand Down Expand Up @@ -489,6 +519,9 @@ def test_list_namespace_with_parent_200(rest_mock: Mocker) -> None:
]


@pytest.mark.filterwarnings(
"ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning"
)
def test_list_namespaces_token_expired(rest_mock: Mocker) -> None:
new_token = "new_jwt_token"
new_header = dict(TEST_HEADERS)
Expand Down
1 change: 0 additions & 1 deletion tests/expressions/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def test_equals_false() -> None:
def test_is_null() -> None:
assert IsNull("foo") == parser.parse("foo is null")
assert IsNull("foo") == parser.parse("foo IS NULL")
assert IsNull("foo") == parser.parse("table.foo IS NULL")


def test_not_null() -> None:
Expand Down

0 comments on commit acd6f5a

Please sign in to comment.