uplsh580 commented on code in PR #61036:
URL: https://github.com/apache/airflow/pull/61036#discussion_r2934718031


##########
airflow-core/tests/unit/cli/commands/test_dag_processor_command.py:
##########
@@ -57,6 +57,29 @@ def test_bundle_names_passed(self, mock_runner, 
configure_testing_dag_bundle):
             dag_processor_command.dag_processor(args)
         assert mock_runner.call_args.kwargs["processor"].bundle_names_to_parse 
== ["testing"]
 
+    @conf_vars({("core", "load_examples"): "False"})
+    
@mock.patch("airflow.cli.commands.dag_processor_command.DagProcessorJobRunner")
+    @mock.patch("airflow.utils.cli.DagBundlesManager", autospec=True)
+    def test_bundle_validation_runs_with_server_context(self, 
mock_manager_cls, mock_runner):
+        mock_runner.return_value.job_type = "DagProcessorJob"
+        captured_ctx = {}
+
+        mock_bundle = mock.MagicMock()
+        mock_bundle.name = "bundle1"
+
+        def capture_env_and_return_bundles():
+            captured_ctx["during_validation"] = 
os.environ.get("_AIRFLOW_PROCESS_CONTEXT")
+            return [mock_bundle]
+
+        mock_manager_cls.return_value.get_all_dag_bundles.side_effect = 
capture_env_and_return_bundles
+
+        os.environ.pop("_AIRFLOW_PROCESS_CONTEXT", None)

Review Comment:
   Addressed the env var leak risk by switching to 
`monkeypatch.delenv("_AIRFLOW_PROCESS_CONTEXT", raising=False)` instead of 
`os.environ.pop`.
   
   Thanks



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