@@ -543,6 +543,19 @@ async def test_async_activity_completion_payload_conversion(
543543 activities = [async_activity ],
544544 workflow_runner = UnsandboxedWorkflowRunner (), # so that we can use isinstance
545545 ):
546+ workflow_context = WorkflowSerializationContext (
547+ namespace = "default" ,
548+ workflow_id = workflow_id ,
549+ )
550+ activity_context = ActivitySerializationContext (
551+ namespace = "default" ,
552+ workflow_id = workflow_id ,
553+ workflow_type = AsyncActivityCompletionSerializationContextTestWorkflow .__name__ ,
554+ activity_type = async_activity .__name__ ,
555+ activity_task_queue = task_queue ,
556+ is_local = False ,
557+ )
558+
546559 act_started_wf_handle = await client .start_workflow (
547560 EventWorkflow .run ,
548561 id = "activity-started-wf-id" ,
@@ -557,19 +570,42 @@ async def test_async_activity_completion_payload_conversion(
557570 workflow_id = workflow_id ,
558571 run_id = wf_handle .first_execution_run_id ,
559572 activity_id = "async-activity-id" ,
560- )
573+ ).with_context (activity_context )
574+
561575 await act_started_wf_handle .result ()
562576 data = TraceData ()
563577 await activity_handle .heartbeat (data )
564578 await activity_handle .complete (data )
565579 result = await wf_handle .result ()
566580
567- assert [item .method for item in result .items ] == [
568- "to_payload" , # Outbound activity input
569- "to_payload" , # Outbound activity heartbeat data
570- "from_payload" , # Inbound activity result
571- "to_payload" , # Outbound workflow result
572- "from_payload" , # Inbound workflow result
581+ print ()
582+ for item in result .items :
583+ print (item )
584+
585+ activity_context_dict = dataclasses .asdict (activity_context )
586+ workflow_context_dict = dataclasses .asdict (workflow_context )
587+
588+ assert result .items == [
589+ TraceItem (
590+ method = "to_payload" ,
591+ context = activity_context_dict , # Outbound activity heartbeat
592+ ),
593+ TraceItem (
594+ method = "to_payload" ,
595+ context = activity_context_dict , # Outbound activity completion
596+ ),
597+ TraceItem (
598+ method = "from_payload" ,
599+ context = activity_context_dict , # Inbound activity result
600+ ),
601+ TraceItem (
602+ method = "to_payload" ,
603+ context = workflow_context_dict , # Outbound workflow result
604+ ),
605+ TraceItem (
606+ method = "from_payload" ,
607+ context = workflow_context_dict , # Inbound workflow result
608+ ),
573609 ]
574610
575611
0 commit comments