jason810496 commented on code in PR #61289:
URL: https://github.com/apache/airflow/pull/61289#discussion_r2754522719
##########
shared/configuration/tests/configuration/test_parser.py:
##########
@@ -790,3 +793,81 @@ def test_set_case_insensitive(self):
test_conf.set("Test", "NewKey", "new_value")
assert test_conf.get("test", "newkey") == "new_value"
assert test_conf.get("TEST", "NEWKEY") == "new_value"
+
+ def
test_configure_parser_from_configuration_description_with_deprecated_options(self):
+ """
+ Test that configure_parser_from_configuration_description respects
deprecated options.
+ """
+ configuration_description = {
+ "test_section": {
+ "options": {
+ "non_deprecated_key": {"default": "non_deprecated_value"},
+ "deprecated_key_version": {
+ "default": "deprecated_value_version",
+ "version_deprecated": "3.0.0",
+ },
+ "deprecated_key_reason": {
+ "default": "deprecated_value_reason",
+ "deprecation_reason": "Some reason",
+ },
+ "none_default_deprecated": {"default": None,
"deprecation_reason": "No default"},
+ }
+ }
+ }
+ parser = ConfigParser()
+ all_vars = {}
+
+ configure_parser_from_configuration_description(parser,
configuration_description, all_vars)
+
+ # Assert that the non-deprecated key is present
+ assert parser.has_option("test_section", "non_deprecated_key")
+ assert parser.get("test_section", "non_deprecated_key") ==
"non_deprecated_value"
+
+ # Assert that the deprecated keys are NOT present
+ assert not parser.has_option("test_section", "deprecated_key_version")
+ assert not parser.has_option("test_section", "deprecated_key_reason")
+
+ # Assert that options with default None are still not set
+ assert not parser.has_option("test_section", "none_default_deprecated")
+
+ def test_get_default_value_deprecated(self):
+ """Test get_default_value for deprecated options where default is
ignored."""
+
+ class TestConfigParser(AirflowConfigParser):
+ def __init__(self):
+ configuration_description = {
+ "test_section": {
+ "options": {
+ "deprecated_key": {
+ "default": "some_value",
+ "deprecation_reason": "deprecated",
+ },
+ "deprecated_key2": {
+ "default": "some_value",
+ "version_deprecated": "2.0.0",
+ },
+ "active_key": {
+ "default": "active_value",
+ },
+ }
+ }
+ }
+ _default_values = ConfigParser()
+ # verify configure_parser_from_configuration_description logic
of skipping
+ configure_parser_from_configuration_description(
+ _default_values, configuration_description, {}
+ )
+ _SharedAirflowConfigParser.__init__(self,
configuration_description, _default_values)
+
+ test_conf = TestConfigParser()
+
+ # get_default_value should return fallback if not found
+ expected_sentinel = object()
+ assert (
+ test_conf.get("test_section", "deprecated_key",
fallback=expected_sentinel) is expected_sentinel
Review Comment:
Fair point! I just updated the tests.
--
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]