@@ -29,10 +29,10 @@ def create_mock_agent(name, response_text="Default response", metrics=None, agen
2929 agent .return_value = mock_result
3030 agent .__call__ = Mock (return_value = mock_result )
3131
32- async def mock_stream_async (* args , ** kwargs ):
33- yield { "result" : mock_result }
32+ async def mock_invoke_async (* args , ** kwargs ):
33+ return mock_result
3434
35- agent .stream_async = MagicMock (side_effect = mock_stream_async )
35+ agent .invoke_async = MagicMock (side_effect = mock_invoke_async )
3636
3737 return agent
3838
@@ -194,14 +194,14 @@ async def test_graph_execution(mock_strands_tracer, mock_use_span, mock_graph, m
194194 assert result .execution_order [0 ].node_id == "start_agent"
195195
196196 # Verify agent calls
197- mock_agents ["start_agent" ].stream_async .assert_called_once ()
197+ mock_agents ["start_agent" ].invoke_async .assert_called_once ()
198198 mock_agents ["multi_agent" ].invoke_async .assert_called_once ()
199- mock_agents ["conditional_agent" ].stream_async .assert_called_once ()
200- mock_agents ["final_agent" ].stream_async .assert_called_once ()
201- mock_agents ["no_metrics_agent" ].stream_async .assert_called_once ()
202- mock_agents ["partial_metrics_agent" ].stream_async .assert_called_once ()
203- string_content_agent .stream_async .assert_called_once ()
204- mock_agents ["blocked_agent" ].stream_async .assert_not_called ()
199+ mock_agents ["conditional_agent" ].invoke_async .assert_called_once ()
200+ mock_agents ["final_agent" ].invoke_async .assert_called_once ()
201+ mock_agents ["no_metrics_agent" ].invoke_async .assert_called_once ()
202+ mock_agents ["partial_metrics_agent" ].invoke_async .assert_called_once ()
203+ string_content_agent .invoke_async .assert_called_once ()
204+ mock_agents ["blocked_agent" ].invoke_async .assert_not_called ()
205205
206206 # Verify metrics aggregation
207207 assert result .accumulated_usage ["totalTokens" ] > 0
@@ -261,12 +261,10 @@ async def test_graph_execution_with_failures(mock_strands_tracer, mock_use_span)
261261 failing_agent .id = "fail_node"
262262 failing_agent .__call__ = Mock (side_effect = Exception ("Simulated failure" ))
263263
264- # Create a proper failing async generator for stream_async
265- async def mock_stream_failure (* args , ** kwargs ):
264+ async def mock_invoke_failure (* args , ** kwargs ):
266265 raise Exception ("Simulated failure" )
267- yield # This will never be reached
268266
269- failing_agent .stream_async = mock_stream_failure
267+ failing_agent .invoke_async = mock_invoke_failure
270268
271269 success_agent = create_mock_agent ("success_agent" , "Success" )
272270
@@ -301,7 +299,7 @@ async def test_graph_edge_cases(mock_strands_tracer, mock_use_span):
301299 result = await graph .invoke_async ([{"text" : "Original task" }])
302300
303301 # Verify entry node was called with original task
304- entry_agent .stream_async .assert_called_once_with ([{"text" : "Original task" }])
302+ entry_agent .invoke_async .assert_called_once_with ([{"text" : "Original task" }])
305303 assert result .status == Status .COMPLETED
306304 mock_strands_tracer .start_multiagent_span .assert_called ()
307305 mock_use_span .assert_called_once ()
@@ -482,8 +480,8 @@ def test_graph_synchronous_execution(mock_strands_tracer, mock_use_span, mock_ag
482480 assert result .execution_order [1 ].node_id == "final_agent"
483481
484482 # Verify agent calls
485- mock_agents ["start_agent" ].stream_async .assert_called_once ()
486- mock_agents ["final_agent" ].stream_async .assert_called_once ()
483+ mock_agents ["start_agent" ].invoke_async .assert_called_once ()
484+ mock_agents ["final_agent" ].invoke_async .assert_called_once ()
487485
488486 # Verify return type is GraphResult
489487 assert isinstance (result , GraphResult )
0 commit comments