@@ -40,7 +40,7 @@ def orchestrator(ctx: task.OrchestrationContext, my_input: int):
4040 result = executor .execute (TEST_INSTANCE_ID , [], new_events )
4141 actions = result .actions
4242
43- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
43+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
4444 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
4545 assert complete_action .result is not None
4646
@@ -62,7 +62,7 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _):
6262 result = executor .execute (TEST_INSTANCE_ID , [], new_events )
6363 actions = result .actions
6464
65- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
65+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
6666 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
6767 assert complete_action .result .value == '"done"' # results are JSON-encoded
6868
@@ -77,7 +77,7 @@ def test_orchestrator_not_registered():
7777 result = executor .execute (TEST_INSTANCE_ID , [], new_events )
7878 actions = result .actions
7979
80- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
80+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
8181 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
8282 assert complete_action .failureDetails .errorType == "OrchestratorNotRegisteredError"
8383 assert complete_action .failureDetails .errorMessage
@@ -137,7 +137,7 @@ def delay_orchestrator(ctx: task.OrchestrationContext, _):
137137 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
138138 actions = result .actions
139139
140- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
140+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
141141 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
142142 assert complete_action .result is not None
143143 assert complete_action .result .value == '"done"' # results are JSON-encoded
@@ -196,7 +196,7 @@ def orchestrator(ctx: task.OrchestrationContext, orchestrator_input):
196196 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
197197 actions = result .actions
198198
199- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
199+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
200200 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
201201 assert complete_action .result .value == encoded_output
202202
@@ -225,7 +225,7 @@ def orchestrator(ctx: task.OrchestrationContext, orchestrator_input):
225225 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
226226 actions = result .actions
227227
228- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
228+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
229229 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
230230 assert complete_action .failureDetails .errorType == 'TaskFailedError' # TODO: Should this be the specific error?
231231 assert str (ex ) in complete_action .failureDetails .errorMessage
@@ -405,7 +405,7 @@ def orchestrator(ctx: task.OrchestrationContext, orchestrator_input):
405405 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
406406 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
407407 actions = result .actions
408- assert len (actions ) == 1
408+ assert len (actions ) == 7
409409 assert actions [0 ].completeOrchestration .failureDetails .errorMessage .__contains__ ("Activity task #1 failed: Kah-BOOOOM!!!" )
410410 assert actions [0 ].id == 7
411411
@@ -433,7 +433,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
433433 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
434434 actions = result .actions
435435
436- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
436+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
437437 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
438438 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
439439 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -461,7 +461,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
461461 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
462462 actions = result .actions
463463
464- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
464+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
465465 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
466466 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
467467 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -491,7 +491,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
491491 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
492492 actions = result .actions
493493
494- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
494+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
495495 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
496496 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
497497 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -522,7 +522,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
522522 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
523523 actions = result .actions
524524
525- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
525+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
526526 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
527527 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
528528 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -556,7 +556,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
556556 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
557557 actions = result .actions
558558
559- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
559+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
560560 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
561561 assert complete_action .result .value == "42"
562562
@@ -586,7 +586,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
586586 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
587587 actions = result .actions
588588
589- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
589+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
590590 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
591591 assert complete_action .failureDetails .errorType == 'TaskFailedError' # TODO: Should this be the specific error?
592592 assert str (ex ) in complete_action .failureDetails .errorMessage
@@ -617,7 +617,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
617617 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
618618 actions = result .actions
619619
620- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
620+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
621621 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
622622 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
623623 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -647,7 +647,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
647647 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
648648 actions = result .actions
649649
650- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
650+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
651651 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
652652 assert complete_action .failureDetails .errorType == 'NonDeterminismError'
653653 assert "1" in complete_action .failureDetails .errorMessage # task ID
@@ -682,7 +682,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
682682 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
683683 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
684684 actions = result .actions
685- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
685+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
686686 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
687687 assert complete_action .result .value == "42"
688688
@@ -718,7 +718,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
718718 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
719719 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
720720 actions = result .actions
721- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
721+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
722722 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
723723 assert complete_action .result .value == "42"
724724
@@ -753,7 +753,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
753753 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
754754 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
755755 actions = result .actions
756- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
756+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
757757 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
758758 assert complete_action .result .value == "42"
759759
@@ -779,7 +779,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
779779 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
780780 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
781781 actions = result .actions
782- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
782+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
783783 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_TERMINATED
784784 assert complete_action .result .value == json .dumps ("terminated!" )
785785
@@ -808,7 +808,7 @@ def orchestrator(ctx: task.OrchestrationContext, input: int):
808808 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
809809 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
810810 actions = result .actions
811- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
811+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
812812 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_CONTINUED_AS_NEW
813813 assert complete_action .result .value == json .dumps (2 )
814814 assert len (complete_action .carryoverEvents ) == (3 if save_events else 0 )
@@ -893,7 +893,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
893893 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
894894 actions = result .actions
895895
896- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
896+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
897897 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
898898 assert complete_action .result .value == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]"
899899
@@ -935,7 +935,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
935935 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
936936 actions = result .actions
937937
938- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
938+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
939939 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
940940 assert complete_action .failureDetails .errorType == 'TaskFailedError' # TODO: Is this the right error type?
941941 assert str (ex ) in complete_action .failureDetails .errorMessage
@@ -983,7 +983,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
983983 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
984984 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
985985 actions = result .actions
986- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
986+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
987987 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
988988 assert complete_action .result .value == encoded_output
989989
@@ -993,7 +993,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
993993 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
994994 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
995995 actions = result .actions
996- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
996+ complete_action = get_and_validate_complete_orchestration_action_list ( 1 , actions )
997997 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
998998 assert complete_action .result .value == encoded_output
999999
@@ -1078,7 +1078,7 @@ def orchestrator(ctx: task.OrchestrationContext, _):
10781078 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
10791079 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
10801080 actions = result .actions
1081- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
1081+ complete_action = get_and_validate_complete_orchestration_action_list ( 3 , actions )
10821082 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_COMPLETED
10831083 assert complete_action .result .value == encoded_output
10841084
@@ -1177,14 +1177,14 @@ def orchestrator(ctx: task.OrchestrationContext, _):
11771177 executor = worker ._OrchestrationExecutor (registry , TEST_LOGGER )
11781178 result = executor .execute (TEST_INSTANCE_ID , old_events , new_events )
11791179 actions = result .actions
1180- complete_action = get_and_validate_single_complete_orchestration_action ( actions )
1180+ complete_action = get_and_validate_complete_orchestration_action_list ( 4 , actions )
11811181 assert complete_action .orchestrationStatus == pb .ORCHESTRATION_STATUS_FAILED
11821182 assert complete_action .failureDetails .errorType == 'TaskFailedError' # TODO: Should this be the specific error?
11831183 assert str (ex ) in complete_action .failureDetails .errorMessage
11841184
11851185
1186- def get_and_validate_single_complete_orchestration_action ( actions : list [pb .OrchestratorAction ]) -> pb .CompleteOrchestrationAction :
1187- assert len (actions ) == 1
1188- assert type (actions [0 ]) is pb .OrchestratorAction
1189- assert actions [0 ].HasField ("completeOrchestration" )
1190- return actions [0 ].completeOrchestration
1186+ def get_and_validate_complete_orchestration_action_list ( expected_action_count : int , actions : list [pb .OrchestratorAction ]) -> pb .CompleteOrchestrationAction :
1187+ assert len (actions ) == expected_action_count
1188+ assert type (actions [- 1 ]) is pb .OrchestratorAction
1189+ assert actions [- 1 ].HasField ("completeOrchestration" )
1190+ return actions [- 1 ].completeOrchestration
0 commit comments