@@ -24,6 +24,17 @@ def generator_function(context):
24
24
25
25
return outputs
26
26
27
+ def generator_function_is_replaying (context ):
28
+ outputs = []
29
+
30
+ outputs .append (context .is_replaying )
31
+ yield context .call_activity ("Hello" , "Tokyo" )
32
+ outputs .append (context .is_replaying )
33
+ yield context .call_activity ("Hello" , "Seattle" )
34
+ outputs .append (context .is_replaying )
35
+ yield context .call_activity ("Hello" , "London" )
36
+ return outputs
37
+
27
38
def generator_function_no_yield (context ):
28
39
outputs = []
29
40
@@ -150,11 +161,11 @@ def add_hello_action(state: OrchestratorState, input_: str):
150
161
state .actions .append ([action ])
151
162
152
163
def add_hello_completed_events (
153
- context_builder : ContextBuilder , id_ : int , result : str ):
164
+ context_builder : ContextBuilder , id_ : int , result : str , is_played = False ):
154
165
context_builder .add_task_scheduled_event (name = 'Hello' , id_ = id_ )
155
166
context_builder .add_orchestrator_completed_event ()
156
167
context_builder .add_orchestrator_started_event ()
157
- context_builder .add_task_completed_event (id_ = id_ , result = result )
168
+ context_builder .add_task_completed_event (id_ = id_ , result = result , is_played = is_played )
158
169
159
170
160
171
def add_hello_failed_events (
@@ -286,6 +297,26 @@ def test_tokyo_and_seattle_and_london_state():
286
297
assert_valid_schema (result )
287
298
assert_orchestration_state_equals (expected , result )
288
299
300
+ def test_sequential_is_replaying ():
301
+ context_builder = ContextBuilder ('test_simple_function' , is_replaying = True )
302
+ add_hello_completed_events (context_builder , 0 , "\" Hello Tokyo!\" " , True )
303
+ add_hello_completed_events (context_builder , 1 , "\" Hello Seattle!\" " , True )
304
+ add_hello_completed_events (context_builder , 2 , "\" Hello London!\" " , True )
305
+
306
+ result = get_orchestration_state_result (
307
+ context_builder , generator_function_is_replaying )
308
+
309
+ expected_state = base_expected_state (
310
+ [True , True , True ])
311
+ add_hello_action (expected_state , 'Tokyo' )
312
+ add_hello_action (expected_state , 'Seattle' )
313
+ add_hello_action (expected_state , 'London' )
314
+ expected_state ._is_done = True
315
+ expected = expected_state .to_json ()
316
+
317
+ assert_valid_schema (result )
318
+ assert_orchestration_state_equals (expected , result )
319
+
289
320
def test_sequential_orchestration_no_yield ():
290
321
context_builder = ContextBuilder ('test_simple_function' )
291
322
add_hello_completed_events (context_builder , 0 , "\" Hello London!\" " )
0 commit comments