uranusjr commented on code in PR #32707:
URL: https://github.com/apache/airflow/pull/32707#discussion_r1272945519


##########
tests/cli/commands/test_scheduler_command.py:
##########
@@ -139,6 +139,30 @@ def test_disable_scheduler_health(
         with pytest.raises(AssertionError):
             
mock_process.assert_has_calls([mock.call(target=serve_health_check)])
 
+    @mock.patch("airflow.cli.commands.scheduler_command.SchedulerJobRunner")
+    @mock.patch("airflow.cli.commands.scheduler_command.Process")
+    @mock.patch("airflow.cli.commands.scheduler_command.run_job", 
side_effect=Exception("run_job failed"))
+    @mock.patch("airflow.cli.commands.scheduler_command.log")
+    def test_run_job_exception_handling(
+        self,
+        mock_log,
+        mock_run_job,
+        mock_process,
+        mock_scheduler_job,
+    ):
+        args = self.parser.parse_args(["scheduler"])
+        scheduler_command.scheduler(args)
+
+        # Make sure that run_job is called, that the exception has been 
logged, and that the serve_logs
+        # sub-process has been terminated
+        mock_run_job.assert_called_once_with(
+            job=mock_scheduler_job().job,
+            execute_callable=mock_scheduler_job()._execute,
+        )
+        mock_log.exception.assert_called_once_with("Exception when running 
scheduler job")
+        mock_process.assert_has_calls([mock.call(target=serve_logs)])
+        mock_process().terminate.assert_called_once()

Review Comment:
   ```suggestion
           mock_process().terminate.assert_called_once_with()
   ```
   
   Also check the arguments



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