@@ -292,7 +292,7 @@ async def test_toolset_with_state_config(self, calculator_toolset_with_state_con
292292 assert add_tool .outputs_to_string is not None
293293 assert subtract_tool .outputs_to_string is None
294294
295- async def test_toolset_state_config_serde (self , calculator_toolset_with_state_config ):
295+ async def test_toolset_state_config_serde (self , calculator_toolset_with_state_config , mcp_tool_cleanup ):
296296 """Test serialization and deserialization of MCPToolset with state configuration."""
297297 toolset = calculator_toolset_with_state_config
298298
@@ -308,20 +308,19 @@ async def test_toolset_state_config_serde(self, calculator_toolset_with_state_co
308308 # Handler should be serialized as a string
309309 assert isinstance (toolset_dict ["data" ]["outputs_to_string" ]["add" ]["handler" ], str )
310310
311- # Test deserialization
312- with patch ( "haystack_integrations.tools.mcp.mcp_toolset. MCPToolset.__init__" , return_value = None ) as mock_init :
313- MCPToolset . from_dict ( toolset_dict )
311+ # Test deserialization with full roundtrip
312+ new_toolset = MCPToolset .from_dict ( toolset_dict )
313+ mcp_tool_cleanup ( new_toolset )
314314
315- mock_init .assert_called_once ()
316- _ , kwargs = mock_init .call_args
317- assert kwargs ["inputs_from_state" ] == {
318- "add" : {"first_number" : "a" },
319- "subtract" : {"first_number" : "a" , "second_number" : "b" },
320- }
321- assert "add" in kwargs ["outputs_to_state" ]
322- assert "add" in kwargs ["outputs_to_string" ]
323- # Handler should be deserialized back to a callable
324- assert callable (kwargs ["outputs_to_string" ]["add" ]["handler" ])
315+ # Verify state configs are correctly deserialized
316+ assert new_toolset .inputs_from_state == {
317+ "add" : {"first_number" : "a" },
318+ "subtract" : {"first_number" : "a" , "second_number" : "b" },
319+ }
320+ assert "add" in new_toolset .outputs_to_state
321+ assert "add" in new_toolset .outputs_to_string
322+ # Handler should be deserialized back to a callable
323+ assert callable (new_toolset .outputs_to_string ["add" ]["handler" ])
325324
326325 async def test_toolset_state_config_unknown_tool_warning (self , caplog ):
327326 """Test that a warning is logged when state config references unknown tools.
0 commit comments