@@ -390,11 +390,16 @@ async def test_broadcast_message_to_agents_activity(self, basic_durable_agent):
390390 "sender" : "TestDurableAgent" ,
391391 }
392392
393- with patch .object (
394- type (basic_durable_agent ), "broadcast_message"
395- ) as mock_broadcast :
396- await basic_durable_agent .broadcast_message_to_agents (message )
397- mock_broadcast .assert_called_once ()
393+ # Mock the activity context
394+ mock_ctx = Mock ()
395+
396+ # The basic_durable_agent fixture doesn't have a broadcast_topic configured,
397+ # so this should execute without error but skip the actual broadcast
398+ basic_durable_agent .broadcast_message_to_agents (
399+ mock_ctx ,
400+ {"message" : message }
401+ )
402+ # Test passes if no exception is raised
398403
399404 @pytest .mark .asyncio
400405 async def test_send_response_back_activity (self , basic_durable_agent ):
@@ -403,13 +408,20 @@ async def test_send_response_back_activity(self, basic_durable_agent):
403408 target_agent = "TargetAgent"
404409 target_instance_id = "target-instance-123"
405410
406- with patch .object (
407- type (basic_durable_agent ), "send_message_to_agent"
408- ) as mock_send :
409- await basic_durable_agent .send_response_back (
410- response , target_agent , target_instance_id
411+ # Mock the activity context and _run_asyncio_task
412+ mock_ctx = Mock ()
413+
414+ with patch .object (basic_durable_agent , '_run_asyncio_task' ) as mock_run_task :
415+ basic_durable_agent .send_response_back (
416+ mock_ctx ,
417+ {
418+ "response" : response ,
419+ "target_agent" : target_agent ,
420+ "target_instance_id" : target_instance_id
421+ }
411422 )
412- mock_send .assert_called_once ()
423+ # Verify the async task was called
424+ mock_run_task .assert_called_once ()
413425
414426 @pytest .mark .asyncio
415427 async def test_finish_workflow_activity (self , basic_durable_agent ):
0 commit comments