4646
4747from tests_common .test_utils .api_fastapi import _check_task_instance_note
4848from tests_common .test_utils .asserts import assert_queries_count
49+ from tests_common .test_utils .config import conf_vars
4950from tests_common .test_utils .db import (
5051 clear_db_runs ,
5152 clear_rendered_ti_fields ,
@@ -833,8 +834,8 @@ def test_offset_limit(self, test_client, one_task_with_many_mapped_tis):
833834 ({"order_by" : "map_index" , "limit" : 100 }, list (range (100 ))),
834835 ({"order_by" : "-map_index" , "limit" : 100 }, list (range (109 , 9 , - 1 ))),
835836 (
836- {"order_by" : "state" , "limit" : 108 },
837- list (range (5 , 25 )) + list (range (25 , 110 )) + list ( range ( 3 )),
837+ {"order_by" : "state" , "limit" : 108 }, # Maximum page limit will limit result to 100 items.
838+ list (range (5 , 25 )) + list (range (25 , 105 )),
838839 ),
839840 (
840841 {"order_by" : "-state" , "limit" : 100 },
@@ -849,6 +850,8 @@ def test_offset_limit(self, test_client, one_task_with_many_mapped_tis):
849850 def test_mapped_instances_order (
850851 self , test_client , session , params , expected_map_indexes , one_task_with_many_mapped_tis
851852 ):
853+ from airflow .configuration import conf
854+
852855 with assert_queries_count (4 ):
853856 response = test_client .get (
854857 "/dags/mapped_tis/dagRuns/run_mapped_tis/taskInstances/task_2/listMapped" ,
@@ -858,7 +861,7 @@ def test_mapped_instances_order(
858861 assert response .status_code == 200
859862 body = response .json ()
860863 assert body ["total_entries" ] == 110
861- assert len (body ["task_instances" ]) == params ["limit" ]
864+ assert len (body ["task_instances" ]) == min ( params ["limit" ], conf . getint ( "api" , "maximum_page_limit" ))
862865 assert expected_map_indexes == [ti ["map_index" ] for ti in body ["task_instances" ]]
863866
864867 # Ordering of nulls values is DB specific.
@@ -870,6 +873,7 @@ def test_mapped_instances_order(
870873 ({"order_by" : "-rendered_map_index" , "limit" : 100 }, [0 ] + list (range (11 , 110 )[::- 1 ])), # Desc
871874 ],
872875 )
876+ @conf_vars ({("api" , "maximum_page_limit" ): "110" })
873877 def test_rendered_map_index_order (
874878 self , test_client , session , params , expected_map_indexes , one_task_with_many_mapped_tis
875879 ):
0 commit comments