@@ -257,10 +257,31 @@ def generator_function_call_activity_with_orchestrator(context):
257257
258258 return outputs
259259
260+ def generator_function_call_activity_with_none_return (context ):
261+ """Simple orchestrator that call activity function which can return None"""
262+ outputs = []
263+
264+ task1 = yield context .call_activity (hello_return_none , "Tokyo" )
265+ task2 = yield context .call_activity (hello_return_none , "Seattle" )
266+ task3 = yield context .call_activity (hello_return_none , "London" )
267+
268+ outputs .append (task1 )
269+ outputs .append (task2 )
270+ outputs .append (task3 )
271+
272+ return outputs
273+
260274@app .activity_trigger (input_name = "myArg" )
261275def Hello (myArg : str ):
262276 return "Hello" + myArg
263277
278+ @app .activity_trigger (input_name = "myArg" )
279+ def hello_return_none (myArg : str ):
280+ if myArg == "London" :
281+ return None
282+ else :
283+ return "Hello" + myArg
284+
264285def base_expected_state (output = None , replay_schema : ReplaySchema = ReplaySchema .V1 ) -> OrchestratorState :
265286 return OrchestratorState (is_done = False , actions = [], output = output , replay_schema = replay_schema )
266287
@@ -270,13 +291,13 @@ def add_timer_fired_events(context_builder: ContextBuilder, id_: int, timestamp:
270291 context_builder .add_orchestrator_started_event ()
271292 context_builder .add_timer_fired_event (id_ = id_ , fire_at = fire_at )
272293
273- def add_hello_action (state : OrchestratorState , input_ : str ):
274- action = CallActivityAction (function_name = 'Hello' , input_ = input_ )
294+ def add_hello_action (state : OrchestratorState , input_ : str , activity_name = "Hello" ):
295+ action = CallActivityAction (function_name = activity_name , input_ = input_ )
275296 state .actions .append ([action ])
276297
277298def add_hello_completed_events (
278- context_builder : ContextBuilder , id_ : int , result : str , is_played = False ):
279- context_builder .add_task_scheduled_event (name = 'Hello' , id_ = id_ )
299+ context_builder : ContextBuilder , id_ : int , result : str , is_played = False , activity_name = "Hello" ):
300+ context_builder .add_task_scheduled_event (name = activity_name , id_ = id_ )
280301 context_builder .add_orchestrator_completed_event ()
281302 context_builder .add_orchestrator_started_event ()
282303 context_builder .add_task_completed_event (id_ = id_ , result = result , is_played = is_played )
@@ -365,6 +386,25 @@ def test_call_activity_with_name():
365386 assert_valid_schema (result )
366387 assert_orchestration_state_equals (expected , result )
367388
389+ def test_call_activity_with_none_return ():
390+ context_builder = ContextBuilder ('test_call_activity_with_none_return' )
391+ add_hello_completed_events (context_builder , 0 , "\" Hello Tokyo!\" " , "hello_return_none" )
392+ add_hello_completed_events (context_builder , 1 , "\" Hello Seattle!\" " , "hello_return_none" )
393+ add_hello_completed_events (context_builder , 2 , None , "hello_return_none" )
394+ result = get_orchestration_state_result (
395+ context_builder , generator_function_call_activity_with_none_return )
396+
397+ expected_state = base_expected_state (
398+ ['Hello Tokyo!' , 'Hello Seattle!' , None ])
399+ add_hello_action (expected_state , 'Tokyo' , "hello_return_none" )
400+ add_hello_action (expected_state , 'Seattle' , "hello_return_none" )
401+ add_hello_action (expected_state , 'London' , "hello_return_none" )
402+ expected_state ._is_done = True
403+ expected = expected_state .to_json ()
404+
405+ assert_valid_schema (result )
406+ assert_orchestration_state_equals (expected , result )
407+
368408def test_call_activity_function_callable_exception ():
369409 context_builder = ContextBuilder ('test_call_activity_by_name_exception' )
370410
0 commit comments