This is an automated email from the ASF dual-hosted git repository.

kaxil pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 919765f3cf7 Rename the max_active_runs recompute test and drop a no-op 
mock (#74483)
919765f3cf7 is described below

commit 919765f3cf737b0cf75a40c44e9b95927d2a52d8
Author: PoAn Yang <[email protected]>
AuthorDate: Sat Oct 10 04:55:59 2026 +0800

    Rename the max_active_runs recompute test and drop a no-op mock (#74483)
    
    * Rename the max_active_runs recompute test and drop a no-op mock
    
    Signed-off-by: PoAn Yang <[email protected]>
    
    * Assert the exact call count in the max_active_runs recompute test
    
    Signed-off-by: PoAn Yang <[email protected]>
    
    ---------
    
    Signed-off-by: PoAn Yang <[email protected]>
---
 airflow-core/tests/unit/jobs/test_scheduler_job.py | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/airflow-core/tests/unit/jobs/test_scheduler_job.py 
b/airflow-core/tests/unit/jobs/test_scheduler_job.py
index 0633e4d2d5f..2a2758bf905 100644
--- a/airflow-core/tests/unit/jobs/test_scheduler_job.py
+++ b/airflow-core/tests/unit/jobs/test_scheduler_job.py
@@ -6114,10 +6114,16 @@ class TestSchedulerJob:
             DagRunType.ASSET_MATERIALIZATION.name,
         ],
     )
-    def test_should_update_dag_next_dagruns_after_run_type(
-        self, run_type, expected, timed_out, session, dag_maker
+    @mock.patch.object(SchedulerJobRunner, "_set_exceeds_max_active_runs", 
autospec=True)
+    def test_exceeds_max_active_runs_recomputed_for_finished_non_backfill_runs(
+        self, mock_set_exceeds_max_active_runs, run_type, expected, timed_out, 
session, dag_maker
     ):
-        """Test that whether next dag run is updated depends on run type"""
+        """
+        Test that the scheduler recomputes the exceeds_max_non_backfill flag 
when a run finishes
+        or times out.
+
+        Backfill runs are the exception because the flag does not count them.
+        """
         with dag_maker(
             schedule="*/1 * * * *",
             max_active_runs=3,
@@ -6145,15 +6151,11 @@ class TestSchedulerJob:
             ti.state = "failed"
         session.flush()
 
-        check_mock = MagicMock()
-        self.job_runner._set_exceeds_max_active_runs = check_mock
-        with patch("airflow.models.dag.DagModel.calculate_dagrun_date_fields") 
as mock_calc:
-            self.job_runner._schedule_dag_run(
-                dag_run=run,
-                session=session,
-            )
-            assert not mock_calc.called
-        assert check_mock.called == expected
+        self.job_runner._schedule_dag_run(
+            dag_run=run,
+            session=session,
+        )
+        assert mock_set_exceeds_max_active_runs.call_count == expected
 
     def test_create_dag_runs(self, dag_maker):
         """

Reply via email to