@@ -275,7 +275,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
275275 assert state .serialized_output == json .dumps ("timed out" )
276276
277277
278- def test_suspend_and_resume ():
278+ def test_suspend_and_resume_preserves_reasons_in_history ():
279279 def orchestrator (ctx : task .OrchestrationContext , _ ):
280280 result = yield ctx .wait_for_external_event ("my_event" )
281281 return result
@@ -290,7 +290,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
290290 assert state is not None
291291
292292 # Suspend the orchestration and wait for it to go into the SUSPENDED state
293- task_hub_client .suspend_orchestration (id )
293+ task_hub_client .suspend_orchestration (id , reason = "maintenance" )
294294 deadline = time .time () + 10
295295 while state .runtime_status == client .OrchestrationStatus .RUNNING :
296296 assert time .time () < deadline , "Timed out waiting for SUSPENDED status"
@@ -308,11 +308,18 @@ def orchestrator(ctx: task.OrchestrationContext, _):
308308 pass
309309
310310 # Resume the orchestration and wait for it to complete
311- task_hub_client .resume_orchestration (id )
311+ task_hub_client .resume_orchestration (id , reason = "maintenance complete" )
312312 state = task_hub_client .wait_for_orchestration_completion (id , timeout = 30 )
313+ events = task_hub_client .get_orchestration_history (id )
313314 assert state is not None
314315 assert state .runtime_status == client .OrchestrationStatus .COMPLETED
315316 assert state .serialized_output == json .dumps (42 )
317+ suspended_event = next (
318+ event for event in events if isinstance (event , history .ExecutionSuspendedEvent ))
319+ resumed_event = next (
320+ event for event in events if isinstance (event , history .ExecutionResumedEvent ))
321+ assert suspended_event .input == "maintenance"
322+ assert resumed_event .input == "maintenance complete"
316323
317324
318325def test_terminate ():
0 commit comments