|
16 | 16 | # under the License. |
17 | 17 | # pylint: disable=redefined-outer-name,unused-argument |
18 | 18 | import os |
| 19 | +from typing import cast |
19 | 20 | from unittest import mock |
20 | 21 | from uuid import UUID |
21 | 22 |
|
|
25 | 26 | import pyiceberg |
26 | 27 | from pyiceberg.catalog import PropertiesUpdateSummary, Table, load_catalog |
27 | 28 | from pyiceberg.catalog.rest import RestCatalog |
28 | | -from pyiceberg.utils.config import Config |
29 | 29 | from pyiceberg.exceptions import ( |
30 | 30 | NamespaceAlreadyExistsError, |
31 | 31 | NoSuchNamespaceError, |
|
41 | 41 | from pyiceberg.table.snapshots import Operation, Snapshot, Summary |
42 | 42 | from pyiceberg.table.sorting import SortField, SortOrder |
43 | 43 | from pyiceberg.transforms import IdentityTransform, TruncateTransform |
| 44 | +from pyiceberg.typedef import RecursiveDict |
44 | 45 | from pyiceberg.types import ( |
45 | 46 | BooleanType, |
46 | 47 | IntegerType, |
47 | 48 | NestedField, |
48 | 49 | StringType, |
49 | 50 | ) |
| 51 | +from pyiceberg.utils.config import Config |
50 | 52 |
|
51 | 53 | TEST_URI = "https://iceberg-test-catalog/" |
52 | 54 | TEST_CREDENTIALS = "client:secret" |
@@ -953,32 +955,34 @@ def test_request_session_with_ssl_client_cert() -> None: |
953 | 955 |
|
954 | 956 | @mock.patch.dict(os.environ, EXAMPLE_ENV) |
955 | 957 | @mock.patch("pyiceberg.catalog.Config.get_catalog_config") |
956 | | -def test_catalog_from_environment_variables(catalog_config_mock, rest_mock) -> None: |
957 | | - catalog_config_mock.return_value = Config._from_environment_variables({}).get("catalog").get("production") |
958 | | - catalog = load_catalog("production") |
| 958 | +def test_catalog_from_environment_variables(catalog_config_mock: mock.Mock) -> None: |
| 959 | + env_config: RecursiveDict = Config._from_environment_variables({}) |
| 960 | + catalog_config_mock.return_value = cast(RecursiveDict, env_config.get("catalog")).get("production") |
| 961 | + catalog = cast(RestCatalog, load_catalog("production")) |
959 | 962 | assert catalog.uri == TEST_URI |
960 | 963 |
|
961 | 964 |
|
962 | 965 | @mock.patch.dict(os.environ, EXAMPLE_ENV) |
963 | 966 | @mock.patch("pyiceberg.catalog._ENV_CONFIG.get_catalog_config") |
964 | | -def test_catalog_from_environment_variables_override(catalog_config_mock, rest_mock) -> None: |
| 967 | +def test_catalog_from_environment_variables_override(catalog_config_mock: mock.Mock, rest_mock: Mocker) -> None: |
965 | 968 | rest_mock.get( |
966 | 969 | "https://other-service.io/api/v1/config", |
967 | 970 | json={"defaults": {}, "overrides": {}}, |
968 | 971 | status_code=200, |
969 | 972 | ) |
| 973 | + env_config: RecursiveDict = Config._from_environment_variables({}) |
970 | 974 |
|
971 | | - catalog_config_mock.return_value = Config._from_environment_variables({}).get("catalog").get("production") |
972 | | - catalog = load_catalog("production", uri="https://other-service.io/api") |
| 975 | + catalog_config_mock.return_value = cast(RecursiveDict, env_config.get("catalog")).get("production") |
| 976 | + catalog = cast(RestCatalog, load_catalog("production", uri="https://other-service.io/api")) |
973 | 977 | assert catalog.uri == "https://other-service.io/api" |
974 | 978 |
|
975 | 979 |
|
976 | | -def test_catalog_from_parameters_empty_env(rest_mock) -> None: |
| 980 | +def test_catalog_from_parameters_empty_env(rest_mock: Mocker) -> None: |
977 | 981 | rest_mock.get( |
978 | | - f"https://other-service.io/api/v1/config", |
| 982 | + "https://other-service.io/api/v1/config", |
979 | 983 | json={"defaults": {}, "overrides": {}}, |
980 | 984 | status_code=200, |
981 | 985 | ) |
982 | 986 |
|
983 | | - catalog = load_catalog("production", uri="https://other-service.io/api") |
| 987 | + catalog = cast(RestCatalog, load_catalog("production", uri="https://other-service.io/api")) |
984 | 988 | assert catalog.uri == "https://other-service.io/api" |
0 commit comments