@@ -102,7 +102,10 @@ async def main():
102102 output = self .start (main )
103103
104104 self .assert_poll_call_functions (
105- output , ["a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" ]
105+ output ,
106+ ["a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" ],
107+ min_results = 1 ,
108+ max_results = 8 ,
106109 )
107110
108111 def test_resume_after_call (self ):
@@ -175,31 +178,39 @@ async def main():
175178
176179 output = self .start (main )
177180 # a, b, c, d are called first. e is not because it depends on a.
178- calls = self .assert_poll_call_functions (output , ["a" , "b" , "c" , "d" ])
181+ calls = self .assert_poll_call_functions (
182+ output , ["a" , "b" , "c" , "d" ], min_results = 1 , max_results = 4
183+ )
179184 correlation_ids .update (call .correlation_id for call in calls )
180185 results = [
181186 CallResult .from_value (i , correlation_id = call .correlation_id )
182187 for i , call in enumerate (calls )
183188 ]
184189 output = self .resume (main , output , results )
185190 # e is called next
186- calls = self .assert_poll_call_functions (output , ["e" ])
191+ calls = self .assert_poll_call_functions (
192+ output , ["e" ], min_results = 1 , max_results = 1
193+ )
187194 correlation_ids .update (call .correlation_id for call in calls )
188195 output = self .resume (
189196 main ,
190197 output ,
191198 [CallResult .from_value (4 , correlation_id = calls [0 ].correlation_id )],
192199 )
193200 # f is called next
194- calls = self .assert_poll_call_functions (output , ["f" ])
201+ calls = self .assert_poll_call_functions (
202+ output , ["f" ], min_results = 1 , max_results = 1
203+ )
195204 correlation_ids .update (call .correlation_id for call in calls )
196205 output = self .resume (
197206 main ,
198207 output ,
199208 [CallResult .from_value (5 , correlation_id = calls [0 ].correlation_id )],
200209 )
201210 # g, h are called next
202- calls = self .assert_poll_call_functions (output , ["g" , "h" ])
211+ calls = self .assert_poll_call_functions (
212+ output , ["g" , "h" ], min_results = 1 , max_results = 2
213+ )
203214 correlation_ids .update (call .correlation_id for call in calls )
204215 output = self .resume (
205216 main ,
@@ -244,7 +255,9 @@ async def main(c_then_d):
244255 )
245256
246257 output = self .start (main , c_then_d )
247- calls = self .assert_poll_call_functions (output , ["a" , "b" , "c" ])
258+ calls = self .assert_poll_call_functions (
259+ output , ["a" , "b" , "c" ], min_results = 1 , max_results = 3
260+ )
248261
249262 call_a , call_b , call_c = calls
250263 a_result , b_result , c_result = 10 , 20 , 30
@@ -253,7 +266,7 @@ async def main(c_then_d):
253266 output ,
254267 [CallResult .from_value (c_result , correlation_id = call_c .correlation_id )],
255268 )
256- self .assert_poll_call_functions (output , ["d" ])
269+ self .assert_poll_call_functions (output , ["d" ], min_results = 1 , max_results = 3 )
257270
258271 output = self .resume (
259272 main , output , [], poll_error = RuntimeError ("too many calls" )
@@ -343,7 +356,9 @@ def assert_empty_poll(self, output: Output):
343356 poll = self .assert_poll (output )
344357 self .assertEqual (len (poll .calls ), 0 )
345358
346- def assert_poll_call_functions (self , output : Output , expect : list [str ]):
359+ def assert_poll_call_functions (
360+ self , output : Output , expect : list [str ], min_results = None , max_results = None
361+ ):
347362 poll = self .assert_poll (output )
348363 # Note: we're not testing endpoint/input here.
349364 # Check function names match:
@@ -355,4 +370,8 @@ def assert_poll_call_functions(self, output: Output, expect: list[str]):
355370 len (set (correlation_ids )),
356371 "correlation IDs were not unique" ,
357372 )
373+ if min_results is not None :
374+ self .assertEqual (min_results , poll .min_results )
375+ if max_results is not None :
376+ self .assertEqual (max_results , poll .max_results )
358377 return poll .calls
0 commit comments