potiuk commented on code in PR #70977:
URL: https://github.com/apache/airflow/pull/70977#discussion_r3774376337


##########
airflow-core/tests/unit/cli/commands/test_config_command.py:
##########
@@ -531,6 +531,61 @@ def test_lint_detects_invalid_config_negative(self, 
stdout_capture):
 
         assert "Invalid value" not in normalized_output
 
+    @pytest.mark.parametrize(
+        ("remove_if_equals", "config_value", "expect_issue"),
+        [
+            pytest.param("removed_value", "removed_value", True, id="match"),
+            pytest.param("removed_value", "kept_value", False, id="no-match"),
+            pytest.param("", "", True, id="empty-string-match"),
+            pytest.param("", "kept_value", False, id="empty-string-no-match"),
+        ],
+    )
+    def test_lint_reports_conditional_removal_only_when_value_matches(
+        self, remove_if_equals, config_value, expect_issue, stdout_capture
+    ):
+        config_change = ConfigChange(
+            config=ConfigParameter("test_section", "test_option"),
+            was_removed=True,
+            remove_if_equals=remove_if_equals,
+        )
+        with (
+            mock.patch.object(config_command, "CONFIGS_CHANGES", 
[config_change]),
+            conf_vars({("test_section", "test_option"): config_value}),
+            stdout_capture as temp_stdout,
+        ):
+            
config_command.lint_config(cli_parser.get_parser().parse_args(["config", 
"lint"]))
+
+        normalized_output = re.sub(r"\s+", " ", temp_stdout.getvalue().strip())
+        expected_message = (
+            "Removed deprecated `test_option` configuration parameter from 
`test_section` section."
+        )
+
+        assert (expected_message in normalized_output) is expect_issue
+
+    @pytest.mark.parametrize(
+        ("section", "option", "value"),
+        [
+            ("core", "hostname", ":"),
+            ("email", "email_backend", 
"airflow.contrib.utils.sendgrid.send_email"),
+            ("elasticsearch", "log_id_template", 
"{dag_id}-{task_id}-{logical_date}-{try_number}"),
+            (
+                "logging",
+                "log_filename_template",
+                "{{ ti.dag_id }}/{{ ti.task_id }}/{{ ts }}/{{ try_number 
}}.log",
+            ),

Review Comment:
   The other `log_filename_template` removal rule (`config_command.py:322-326`) 
isn't covered here — it's one of the three `breaking=True` ones.
   
   ```suggestion
               ),
               (
                   "logging",
                   "log_filename_template",
                   "dag_id={{ ti.dag_id }}/run_id={{ ti.run_id }}/task_id={{ 
ti.task_id }}/"
                   "{% if ti.map_index >= 0 %}map_index={{ ti.map_index }}/{% 
endif %}"
                   "attempt={{ try_number }}.log",
               ),
   ```
   



-- 
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]

Reply via email to