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


##########
tests/cli/commands/test_scheduler_command.py:
##########
@@ -139,6 +139,31 @@ 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)
+
+        # TODO: the mock run_job should be called with mock job_runner.job and 
mock job_runner._execute
+        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)])

Review Comment:
   Is this called more than once? If not this should use 
`assert_called_once_with` as well.



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