ferruzzi commented on code in PR #70416:
URL: https://github.com/apache/airflow/pull/70416#discussion_r3798068103


##########
airflow-core/tests/unit/api/common/test_airflow_health.py:
##########
@@ -16,127 +16,246 @@
 # under the License.
 from __future__ import annotations
 
-from datetime import datetime
+from datetime import datetime, timedelta
 from unittest.mock import MagicMock, patch
 
 import pytest
 
+from airflow._shared.timezones import timezone
 from airflow.api.common.airflow_health import (
+    DEGRADED,
+    DOWN,
     HEALTHY,
     UNHEALTHY,
     get_airflow_health,
+    get_jobs_health,
 )
-from airflow.jobs.job import Job
+from airflow.jobs.job import Job, JobState
+from airflow.jobs.scheduler_job_runner import SchedulerJobRunner
+from airflow.jobs.triggerer_job_runner import TriggererJobRunner
+from airflow.utils.session import provide_session
+
+from tests_common.test_utils.db import clear_db_jobs
 
 pytestmark = pytest.mark.db_test
 
 
-@patch("airflow.api.common.airflow_health.SchedulerJobRunner.most_recent_job", 
return_value=None)
-@patch("airflow.api.common.airflow_health.TriggererJobRunner.most_recent_job", 
return_value=None)
-@patch("airflow.api.common.airflow_health.DagProcessorJobRunner.most_recent_job",
 return_value=None)
-def test_get_airflow_health_only_metadatabase_healthy(
-    latest_scheduler_job_mock,
-    latest_triggerer_job_mock,
-    latest_dag_processor_job_mock,
-):
+@patch("airflow.api.common.airflow_health.get_jobs_health")
+def test_get_airflow_health_only_metadatabase_healthy(mock_get_jobs_health):
+    mock_get_jobs_health.side_effect = [[], [], []]

Review Comment:
   I think it looks right.   Just make a pass on the docs and see which of 
those need updating, I see a few references to a `null` value which I don't 
think are accurate now with that change.



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