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

pierrejeambrun pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new e3cd986be0d [v3-1-test] Add number of queries guard for public tasks 
(#57646) (#57664)
e3cd986be0d is described below

commit e3cd986be0dbc9c2959205cb91931a2f3bc32f3d
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Nov 4 14:04:58 2025 +0100

    [v3-1-test] Add number of queries guard for public tasks (#57646) (#57664)
    
    (cherry picked from commit 4f797a41881362bfa18ce3b5fa7006ef08cc8f09)
    
    Co-authored-by: Pierre Jeambrun <[email protected]>
---
 .../core_api/routes/public/test_tasks.py           | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py
index 95b279af590..327446f5aa8 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_tasks.py
@@ -26,6 +26,7 @@ from airflow.providers.standard.operators.empty import 
EmptyOperator
 from airflow.sdk import DAG
 from airflow.sdk.definitions._internal.expandinput import EXPAND_INPUT_EMPTY
 
+from tests_common.test_utils.asserts import assert_queries_count
 from tests_common.test_utils.dag import sync_dag_to_db, sync_dags_to_db
 from tests_common.test_utils.db import (
     clear_db_dag_bundles,
@@ -386,7 +387,8 @@ class TestGetTasks(TestTaskEndpoint):
             ],
             "total_entries": 2,
         }
-        response = test_client.get(f"{self.api_prefix}/{self.dag_id}/tasks")
+        with assert_queries_count(2):
+            response = 
test_client.get(f"{self.api_prefix}/{self.dag_id}/tasks")
         assert response.status_code == 200
         assert response.json() == expected
 
@@ -460,7 +462,9 @@ class TestGetTasks(TestTaskEndpoint):
             ],
             "total_entries": 2,
         }
-        response = 
test_client.get(f"{self.api_prefix}/{self.mapped_dag_id}/tasks")
+
+        with assert_queries_count(2):
+            response = 
test_client.get(f"{self.api_prefix}/{self.mapped_dag_id}/tasks")
         assert response.status_code == 200
         assert response.json() == expected
 
@@ -514,23 +518,27 @@ class TestGetTasks(TestTaskEndpoint):
             ],
             "total_entries": len(downstream_dict),
         }
-        response = 
test_client.get(f"{self.api_prefix}/{self.unscheduled_dag_id}/tasks")
+
+        with assert_queries_count(2):
+            response = 
test_client.get(f"{self.api_prefix}/{self.unscheduled_dag_id}/tasks")
         assert response.status_code == 200
         assert response.json() == expected
 
     def test_should_respond_200_ascending_order_by_start_date(self, 
test_client):
-        response = test_client.get(
-            f"{self.api_prefix}/{self.dag_id}/tasks?order_by=start_date",
-        )
+        with assert_queries_count(2):
+            response = test_client.get(
+                f"{self.api_prefix}/{self.dag_id}/tasks?order_by=start_date",
+            )
         assert response.status_code == 200
         assert self.task1_start_date < self.task2_start_date
         assert response.json()["tasks"][0]["task_id"] == self.task_id
         assert response.json()["tasks"][1]["task_id"] == self.task_id2
 
     def test_should_respond_200_descending_order_by_start_date(self, 
test_client):
-        response = test_client.get(
-            f"{self.api_prefix}/{self.dag_id}/tasks?order_by=-start_date",
-        )
+        with assert_queries_count(2):
+            response = test_client.get(
+                f"{self.api_prefix}/{self.dag_id}/tasks?order_by=-start_date",
+            )
         assert response.status_code == 200
         # - means is descending
         assert self.task1_start_date < self.task2_start_date

Reply via email to