Bowrna commented on code in PR #34457:
URL: https://github.com/apache/airflow/pull/34457#discussion_r1518546357


##########
tests/jobs/test_base_job.py:
##########
@@ -205,15 +205,17 @@ def test_is_alive_scheduler(self, job_type):
         assert job.is_alive() is False, "Completed jobs even with recent 
heartbeat should not be alive"
 
     def test_heartbeat_failed(self):
-        when = timezone.utcnow() - datetime.timedelta(seconds=60)
-        mock_session = Mock(name="MockSession")
-        mock_session.commit.side_effect = OperationalError("Force fail", {}, 
None)
-        job = Job(heartrate=10, state=State.RUNNING)
-        job.latest_heartbeat = when
-
-        job.heartbeat(heartbeat_callback=lambda: None, session=mock_session)
-
-        assert job.latest_heartbeat == when, "attribute not updated when 
heartbeat fails"
+        try:
+            when = timezone.utcnow() - datetime.timedelta(seconds=60)
+            mock_session = Mock(name="MockSession")
+            mock_session.commit.side_effect = OperationalError("Force fail", 
{}, None)
+            job = Job(heartrate=10, state=State.RUNNING)
+            job.latest_heartbeat = when
+            job.heartbeat(heartbeat_callback=lambda: None, 
session=mock_session)
+            assert job.latest_heartbeat == when, "attribute not updated when 
heartbeat fails"
+            assert job.heartbeat_failed
+        except OperationalError as excinfo:

Review Comment:
   @potiuk I wrongly thought that OperationalError will be thrown to this code, 
without checking that that exception is handled and the right error messages 
and params are set. I have removed that part of the code.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to