@@ -257,10 +257,31 @@ def generator_function_call_activity_with_orchestrator(context):
257
257
258
258
return outputs
259
259
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
+
260
274
@app .activity_trigger (input_name = "myArg" )
261
275
def Hello (myArg : str ):
262
276
return "Hello" + myArg
263
277
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
+
264
285
def base_expected_state (output = None , replay_schema : ReplaySchema = ReplaySchema .V1 ) -> OrchestratorState :
265
286
return OrchestratorState (is_done = False , actions = [], output = output , replay_schema = replay_schema )
266
287
@@ -270,13 +291,13 @@ def add_timer_fired_events(context_builder: ContextBuilder, id_: int, timestamp:
270
291
context_builder .add_orchestrator_started_event ()
271
292
context_builder .add_timer_fired_event (id_ = id_ , fire_at = fire_at )
272
293
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_ )
275
296
state .actions .append ([action ])
276
297
277
298
def 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_ )
280
301
context_builder .add_orchestrator_completed_event ()
281
302
context_builder .add_orchestrator_started_event ()
282
303
context_builder .add_task_completed_event (id_ = id_ , result = result , is_played = is_played )
@@ -365,6 +386,25 @@ def test_call_activity_with_name():
365
386
assert_valid_schema (result )
366
387
assert_orchestration_state_equals (expected , result )
367
388
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
+
368
408
def test_call_activity_function_callable_exception ():
369
409
context_builder = ContextBuilder ('test_call_activity_by_name_exception' )
370
410
0 commit comments