66
77import pytest
88
9+ from grafi .tools .function_calls .function_call_tool import FunctionCallTool
910from grafi .tools .function_calls .impl .duckduckgo_tool import DuckDuckGoTool
1011from grafi .tools .function_calls .impl .tavily_tool import TavilyTool
1112from grafi .tools .llms .impl .claude_tool import ClaudeTool
@@ -44,6 +45,7 @@ async def test_tool_factory_openai_tool():
4445@pytest .mark .asyncio
4546async def test_tool_factory_claude_tool ():
4647 """Test factory creates ClaudeTool correctly."""
48+ ToolFactory .register_tool_class ("ClaudeTool" , ClaudeTool )
4749 data = {
4850 "class" : "ClaudeTool" ,
4951 "tool_id" : "test-id" ,
@@ -69,6 +71,7 @@ async def test_tool_factory_claude_tool():
6971@pytest .mark .asyncio
7072async def test_tool_factory_deepseek_tool ():
7173 """Test factory creates DeepseekTool correctly."""
74+ ToolFactory .register_tool_class ("DeepseekTool" , DeepseekTool )
7275 data = {
7376 "class" : "DeepseekTool" ,
7477 "tool_id" : "test-id" ,
@@ -93,6 +96,7 @@ async def test_tool_factory_deepseek_tool():
9396@pytest .mark .asyncio
9497async def test_tool_factory_gemini_tool ():
9598 """Test factory creates GeminiTool correctly."""
99+ ToolFactory .register_tool_class ("GeminiTool" , GeminiTool )
96100 data = {
97101 "class" : "GeminiTool" ,
98102 "tool_id" : "test-id" ,
@@ -116,6 +120,7 @@ async def test_tool_factory_gemini_tool():
116120@pytest .mark .asyncio
117121async def test_tool_factory_ollama_tool ():
118122 """Test factory creates OllamaTool correctly."""
123+ ToolFactory .register_tool_class ("OllamaTool" , OllamaTool )
119124 data = {
120125 "class" : "OllamaTool" ,
121126 "tool_id" : "test-id" ,
@@ -140,6 +145,7 @@ async def test_tool_factory_ollama_tool():
140145@pytest .mark .asyncio
141146async def test_tool_factory_openrouter_tool ():
142147 """Test factory creates OpenRouterTool correctly."""
148+ ToolFactory .register_tool_class ("OpenRouterTool" , OpenRouterTool )
143149 data = {
144150 "class" : "OpenRouterTool" ,
145151 "tool_id" : "test-id" ,
@@ -165,6 +171,7 @@ async def test_tool_factory_openrouter_tool():
165171@pytest .mark .asyncio
166172async def test_tool_factory_duckduckgo_tool ():
167173 """Test factory creates DuckDuckGoTool correctly."""
174+ ToolFactory .register_tool_class ("DuckDuckGoTool" , DuckDuckGoTool )
168175 data = {
169176 "class" : "DuckDuckGoTool" ,
170177 "tool_id" : "test-id" ,
@@ -185,6 +192,7 @@ async def test_tool_factory_duckduckgo_tool():
185192@pytest .mark .asyncio
186193async def test_tool_factory_tavily_tool ():
187194 """Test factory creates TavilyTool correctly."""
195+ ToolFactory .register_tool_class ("TavilyTool" , TavilyTool )
188196 # Set a dummy API key for test
189197 os .environ ["TAVILY_API_KEY" ] = "test_key"
190198
@@ -261,6 +269,7 @@ async def test_tool_factory_roundtrip_openai():
261269async def test_tool_factory_roundtrip_claude ():
262270 """Test serialization and deserialization roundtrip for ClaudeTool."""
263271 # Create original tool using builder
272+ ToolFactory .register_tool_class ("ClaudeTool" , ClaudeTool )
264273 original = (
265274 ClaudeTool .builder ()
266275 .name ("test_claude" )
@@ -340,7 +349,6 @@ async def from_dict(cls, data):
340349def test_tool_factory_is_registered ():
341350 """Test checking if a class is registered."""
342351 assert ToolFactory .is_registered ("OpenAITool" )
343- assert ToolFactory .is_registered ("ClaudeTool" )
344352 assert not ToolFactory .is_registered ("NonExistentTool" )
345353
346354
@@ -350,15 +358,9 @@ def test_tool_factory_get_registered_classes():
350358
351359 # Check some expected classes are in the registry
352360 assert "OpenAITool" in registered
353- assert "ClaudeTool" in registered
354- assert "DeepseekTool" in registered
355- assert "GeminiTool" in registered
356- assert "OllamaTool" in registered
357- assert "OpenRouterTool" in registered
358- assert "TavilyTool" in registered
359- assert "DuckDuckGoTool" in registered
361+ assert "FunctionCallTool" in registered
360362 assert "FunctionTool" in registered
361363
362364 # Verify the classes are correct
363365 assert registered ["OpenAITool" ] == OpenAITool
364- assert registered ["ClaudeTool " ] == ClaudeTool
366+ assert registered ["FunctionCallTool " ] == FunctionCallTool
0 commit comments