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


##########
tests/api/common/test_airflow_health.py:
##########
@@ -17,24 +17,26 @@
 from __future__ import annotations
 
 from datetime import datetime
-from unittest.mock import MagicMock
+from unittest.mock import MagicMock, patch
+
+import pytest
 
 from airflow.api.common.airflow_health import (
     HEALTHY,
     UNHEALTHY,
-    DagProcessorJobRunner,
-    SchedulerJobRunner,
-    TriggererJobRunner,
     get_airflow_health,
 )
 
+pytestmark = pytest.mark.db_test
 
-def test_get_airflow_health_only_metadatabase_healthy():
-    SchedulerJobRunner.most_recent_job = MagicMock(return_value=None)
-    TriggererJobRunner.most_recent_job = MagicMock(return_value=None)
-    DagProcessorJobRunner.most_recent_job = MagicMock(return_value=None)
-    health_status = get_airflow_health()
 
+@patch("airflow.api.common.airflow_health.SchedulerJobRunner.most_recent_job", 
return_value=None)

Review Comment:
   These test had bad side-effects on other tests because most_recent_job 
remained patched with MagicMock after the tests completed.



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