@@ -51,16 +51,16 @@ def test_handler_registration_and_retrieval(self):
5151 def dummy_handler (event , context ):
5252 return {"status" : "ok" }
5353
54- def child_handler (payload : str | None ) -> str | None :
55- return json . dumps ( {"result" : "child_result" })
54+ def child_handler (event , context ) :
55+ return {"result" : "child_result" }
5656
5757 with DurableFunctionTestRunner (handler = dummy_handler ) as runner :
5858 # Register handler
5959 runner .register_handler ("child-function" , child_handler )
6060
61- # Verify handler can be retrieved
61+ # Verify handler can be retrieved (returns wrapped marshalled handler)
6262 retrieved = runner .get_handler ("child-function" )
63- assert retrieved is child_handler
63+ assert retrieved is not None
6464
6565 # Verify non-existent handler returns None
6666 assert runner .get_handler ("non-existent" ) is None
@@ -76,19 +76,19 @@ def dummy_handler(event, context):
7676 return {"status" : "ok" }
7777
7878 handlers = {
79- "handler-a" : lambda p : ' {"result": "a"}' ,
80- "handler-b" : lambda p : ' {"result": "b"}' ,
81- "handler-c" : lambda p : ' {"result": "c"}' ,
79+ "handler-a" : lambda event , context : {"result" : "a" },
80+ "handler-b" : lambda event , context : {"result" : "b" },
81+ "handler-c" : lambda event , context : {"result" : "c" },
8282 }
8383
8484 with DurableFunctionTestRunner (handler = dummy_handler ) as runner :
8585 # Register all handlers
8686 for name , handler in handlers .items ():
8787 runner .register_handler (name , handler )
8888
89- # Verify all handlers are retrievable
90- for name , handler in handlers . items () :
91- assert runner .get_handler (name ) is handler
89+ # Verify all handlers are retrievable (returns wrapped marshalled handlers)
90+ for name in handlers :
91+ assert runner .get_handler (name ) is not None
9292
9393 def test_handler_registration_validation (self ):
9494 """
@@ -360,22 +360,22 @@ def test_non_durable_function_synchronous_execution(self):
360360 """
361361 execution_order = []
362362
363- def child_handler (payload : str | None ) -> str | None :
363+ def child_handler (event , context ) :
364364 execution_order .append ("child_executed" )
365- data = json . loads ( payload ) if payload else {}
366- return json . dumps ( {"processed" : data . get ( " value" , 0 ) * 2 })
365+ value = event . get ( "value" , 0 ) if event else 0
366+ return {"processed" : value * 2 }
367367
368368 def dummy_handler (event , context ):
369369 return {"status" : "ok" }
370370
371371 with DurableFunctionTestRunner (handler = dummy_handler ) as runner :
372372 runner .register_handler ("sync-child" , child_handler )
373373
374- # Get the handler and invoke it directly (simulating synchronous execution)
374+ # Get the marshalled handler and invoke it directly (simulating synchronous execution)
375375 handler = runner .get_handler ("sync-child" )
376376 assert handler is not None
377377
378- # Execute synchronously
378+ # Execute synchronously (marshalled handler takes JSON string payload)
379379 result = handler ('{"value": 21}' )
380380 execution_order .append ("after_child" )
381381
@@ -390,17 +390,15 @@ def test_non_durable_function_result_serialization(self):
390390 _Requirements: 8.2_
391391 """
392392
393- def child_handler (payload : str | None ) -> str | None :
394- # Handler returns serialized JSON string
395- return json .dumps (
396- {
397- "string" : "value" ,
398- "number" : 123 ,
399- "boolean" : True ,
400- "array" : [1 , 2 , 3 ],
401- "nested" : {"key" : "value" },
402- }
403- )
393+ def child_handler (event , context ):
394+ # Handler returns dict (Lambda-style), marshalled handler serializes it
395+ return {
396+ "string" : "value" ,
397+ "number" : 123 ,
398+ "boolean" : True ,
399+ "array" : [1 , 2 , 3 ],
400+ "nested" : {"key" : "value" },
401+ }
404402
405403 def dummy_handler (event , context ):
406404 return {"status" : "ok" }
@@ -411,7 +409,7 @@ def dummy_handler(event, context):
411409 handler = runner .get_handler ("serializing-child" )
412410 result = handler (None )
413411
414- # Verify result is valid JSON
412+ # Verify result is valid JSON (marshalled handler serializes the dict)
415413 parsed = json .loads (result )
416414 assert parsed ["string" ] == "value"
417415 assert parsed ["number" ] == 123
@@ -426,7 +424,7 @@ def test_non_durable_function_exception_capture(self):
426424 _Requirements: 8.3_
427425 """
428426
429- def failing_child (payload : str | None ) -> str | None :
427+ def failing_child (event , context ) :
430428 raise RuntimeError ("Child function failed" )
431429
432430 def dummy_handler (event , context ):
@@ -437,6 +435,6 @@ def dummy_handler(event, context):
437435
438436 handler = runner .get_handler ("failing-child" )
439437
440- # Verify exception is raised
438+ # Verify exception is raised (marshalled handler propagates exceptions)
441439 with pytest .raises (RuntimeError , match = "Child function failed" ):
442440 handler ('{"input": "data"}' )
0 commit comments