@@ -70,23 +70,22 @@ def test_agent_tool_load_returns_correct_subtype(self, tool_data: dict, expected
7070 assert loaded_tool .name == tool_data ["name" ]
7171 assert loaded_tool .description == tool_data ["description" ]
7272
73- if isinstance (loaded_tool , UnknownAgentTool ):
73+ if expected_type is UnknownAgentTool :
74+ assert isinstance (loaded_tool , UnknownAgentTool )
7475 assert loaded_tool .type == tool_data ["type" ]
7576 else :
7677 assert loaded_tool ._type == expected_type ._type
7778
78- # Handle configuration comparison based on tool type
7979 if "configuration" in tool_data :
80- if isinstance ( loaded_tool , QueryKnowledgeGraphAgentTool ) :
81- # For QueryKnowledgeGraph, we expect a structured configuration object
80+ if expected_type is QueryKnowledgeGraphAgentTool :
81+ assert isinstance ( loaded_tool , QueryKnowledgeGraphAgentTool )
8282 assert isinstance (loaded_tool .configuration , QueryKnowledgeGraphAgentToolConfiguration )
83- # Compare by serializing the structured object back to dict
8483 assert loaded_tool .configuration .dump (camel_case = True ) == tool_data ["configuration" ]
85- elif isinstance ( loaded_tool , UnknownAgentTool ) :
86- # For other tools (like UnknownAgentTool), configuration should be a dict
84+ elif expected_type is UnknownAgentTool :
85+ assert isinstance ( loaded_tool , UnknownAgentTool )
8786 assert loaded_tool .configuration == tool_data ["configuration" ]
8887 else :
89- raise TypeError (f"Unhandled tool type in test case: { type ( loaded_tool ) } " )
88+ raise TypeError (f"Unhandled tool type in test case: { expected_type } " )
9089
9190 def test_unknown_agent_tool_preserves_custom_type (self ) -> None :
9291 """Test that UnknownAgentTool preserves the original type string."""
@@ -111,9 +110,10 @@ class TestAgentToolDump:
111110 def test_agent_tool_dump_returns_correct_type (self , tool_data : dict , expected_type : type [AgentTool ]) -> None :
112111 """Test that AgentTool.dump() returns the correct type."""
113112 loaded_tool = AgentTool ._load (tool_data )
113+ assert isinstance (loaded_tool , expected_type )
114114 dumped_tool = loaded_tool .dump (camel_case = True )
115115
116- if isinstance ( loaded_tool , UnknownAgentTool ) :
116+ if expected_type is UnknownAgentTool :
117117 assert dumped_tool ["type" ] == unknown_example ["type" ]
118118 else :
119119 assert dumped_tool ["type" ] == expected_type ._type
@@ -156,9 +156,10 @@ class TestAgentToolUpsert:
156156 def test_agent_tool_upsert_returns_correct_type (self , tool_data : dict , expected_type : type [AgentTool ]) -> None :
157157 """Test that AgentToolUpsert.dump() returns the correct type."""
158158 loaded_tool = AgentTool ._load (tool_data )
159+ assert isinstance (loaded_tool , expected_type )
159160 dumped_tool = loaded_tool .as_write ().dump (camel_case = True )
160161
161- if isinstance ( loaded_tool , UnknownAgentTool ) :
162+ if expected_type is UnknownAgentTool :
162163 assert dumped_tool ["type" ] == unknown_example ["type" ]
163164 else :
164165 assert dumped_tool ["type" ] == expected_type ._type
0 commit comments