diff --git a/azure/durable_functions/models/Task.py b/azure/durable_functions/models/Task.py index 5749d798..8c2be5fb 100644 --- a/azure/durable_functions/models/Task.py +++ b/azure/durable_functions/models/Task.py @@ -159,6 +159,9 @@ def __init__(self, tasks: List[TaskBase], compound_action_constructor=None): self.completed_tasks: List[TaskBase] = [] self.children = tasks + if len(self.children) == 0: + self.state = TaskState.SUCCEEDED + def handle_completion(self, child: TaskBase): """Manage sub-task completion events. diff --git a/tests/orchestrator/test_task_any.py b/tests/orchestrator/test_task_any.py index 57f49a28..f91fdbfc 100644 --- a/tests/orchestrator/test_task_any.py +++ b/tests/orchestrator/test_task_any.py @@ -14,6 +14,19 @@ def generator_function(context): except: return "exception" +def generator_function_no_activity(context): + yield context.task_any([]) + return "Done!" + +def test_continues_on_zero_inner_tasks(): + context_builder = ContextBuilder() + result = get_orchestration_state_result( + context_builder, generator_function_no_activity) + expected_state = base_expected_state("Done!") + expected_state._is_done = True + expected = expected_state.to_json() + assert_orchestration_state_equals(expected, result) + def test_continues_on_zero_results(): context_builder = ContextBuilder() result = get_orchestration_state_result(