kevinjqliu commented on code in PR #1464:
URL: https://github.com/apache/iceberg-python/pull/1464#discussion_r1896047664
##########
tests/utils/test_config.py:
##########
@@ -93,3 +94,61 @@ def
test_from_configuration_files_get_typed_value(tmp_path_factory: pytest.TempP
assert Config().get_bool("legacy-current-snapshot-id")
assert Config().get_int("max-workers") == 4
+
+
[email protected](
+ "config_location, config_content, expected_result",
Review Comment:
nit: config_content and expected_result are always the same, we can use one
of them, write to the file and verify that it reads back the same
##########
tests/utils/test_config.py:
##########
@@ -93,3 +94,61 @@ def
test_from_configuration_files_get_typed_value(tmp_path_factory: pytest.TempP
assert Config().get_bool("legacy-current-snapshot-id")
assert Config().get_int("max-workers") == 4
+
+
[email protected](
+ "config_location, config_content, expected_result",
+ [
+ (
+ "config",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "home",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "current",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ ("none", None, None),
+ ],
+)
+def test_from_multiple_configuration_files(
Review Comment:
nit can we also test the order of lookup here?
##########
tests/utils/test_config.py:
##########
@@ -93,3 +94,61 @@ def
test_from_configuration_files_get_typed_value(tmp_path_factory: pytest.TempP
assert Config().get_bool("legacy-current-snapshot-id")
assert Config().get_int("max-workers") == 4
+
+
[email protected](
+ "config_location, config_content, expected_result",
+ [
+ (
+ "config",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "home",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "current",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ ("none", None, None),
+ ],
+)
+def test_from_multiple_configuration_files(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path_factory: pytest.TempPathFactory,
+ config_location: str,
+ config_content: Optional[Dict[str, Any]],
+ expected_result: Optional[Dict[str, Any]],
+) -> None:
+ def create_config_file(directory: str, content: Optional[Dict[str, Any]])
-> None:
+ config_file_path = os.path.join(directory, ".pyiceberg.yaml")
+ with open(config_file_path, "w", encoding="utf-8") as file:
Review Comment:
nit:
```suggestion
with open(config_file_path, "w", encoding=UTF8) as file:
```
##########
tests/utils/test_config.py:
##########
@@ -93,3 +94,61 @@ def
test_from_configuration_files_get_typed_value(tmp_path_factory: pytest.TempP
assert Config().get_bool("legacy-current-snapshot-id")
assert Config().get_int("max-workers") == 4
+
+
[email protected](
+ "config_location, config_content, expected_result",
+ [
+ (
+ "config",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "home",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ (
+ "current",
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ {"catalog": {"default": {"uri": "https://service.io/api"}}},
+ ),
+ ("none", None, None),
+ ],
+)
+def test_from_multiple_configuration_files(
Review Comment:
we want to test both home directory and current directory here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]