@@ -504,7 +504,7 @@ class TestEnsureRegistrations:
504504 @pytest .mark .asyncio
505505 async def test_ensure_registrations_empty (self ):
506506 """Test ensure_registrations with no pending tools."""
507- with patch ("chuk_tool_processor.registry.decorators._pending_registrations " , []):
507+ with patch ("chuk_tool_processor.registry.decorators._PENDING_REGISTRATIONS " , []):
508508 await ensure_registrations ()
509509 # Should complete without error
510510
@@ -514,14 +514,17 @@ async def test_ensure_registrations_with_pending(self):
514514 mock_registry = AsyncMock ()
515515 mock_registry .register_tool = AsyncMock ()
516516
517- # Create pending registrations
518- pending = [
519- ("tool1" , ValidatedTool , {"namespace" : "default" }),
520- ("tool2" , ValidatedTool , {"namespace" : "custom" }),
521- ]
517+ # Create async registration functions
518+ async def reg1 ():
519+ await mock_registry .register_tool (ValidatedTool , name = "tool1" , namespace = "default" , metadata = {})
520+
521+ async def reg2 ():
522+ await mock_registry .register_tool (ValidatedTool , name = "tool2" , namespace = "custom" , metadata = {})
523+
524+ pending = [reg1 , reg2 ]
522525
523526 with (
524- patch ("chuk_tool_processor.registry.decorators._pending_registrations " , pending ),
527+ patch ("chuk_tool_processor.registry.decorators._PENDING_REGISTRATIONS " , pending ),
525528 patch (
526529 "chuk_tool_processor.registry.provider.ToolRegistryProvider.get_registry" , return_value = mock_registry
527530 ),
@@ -537,10 +540,14 @@ async def test_ensure_registrations_clears_pending(self):
537540 mock_registry = AsyncMock ()
538541 mock_registry .register_tool = AsyncMock ()
539542
540- pending = [("tool1" , ValidatedTool , {})]
543+ # Create async registration function
544+ async def reg1 ():
545+ await mock_registry .register_tool (ValidatedTool , name = "tool1" , namespace = "default" , metadata = {})
546+
547+ pending = [reg1 ]
541548
542549 with (
543- patch ("chuk_tool_processor.registry.decorators._pending_registrations " , pending ) as pending_list ,
550+ patch ("chuk_tool_processor.registry.decorators._PENDING_REGISTRATIONS " , pending ) as pending_list ,
544551 patch (
545552 "chuk_tool_processor.registry.provider.ToolRegistryProvider.get_registry" , return_value = mock_registry
546553 ),
@@ -692,21 +699,17 @@ class Arguments(BaseModel):
692699 async def _execute (self , value : str , count : int ):
693700 return {"result" : value * count }
694701
702+ # Process pending registrations
703+ await ensure_registrations ()
704+
695705 # Tool should be registered
696706 mock_registry .register_tool .assert_called ()
697707
698- # Should be in decorated tools
699- with patch ("chuk_tool_processor.registry.decorators._decorated_tools" , []) as decorated :
700-
701- @register_tool (name = "another" )
702- class AnotherTool (ValidatedTool ):
703- class Arguments (BaseModel ):
704- x : int
705-
706- async def _execute (self , x : int ):
707- return {"result" : x }
708-
709- assert len (decorated ) == 1
708+ # Verify the tool was registered with correct parameters
709+ call_args = mock_registry .register_tool .call_args
710+ assert call_args is not None
711+ assert call_args .kwargs ["name" ] == "integration_tool"
712+ assert call_args .kwargs ["namespace" ] == "test"
710713
711714 def test_function_to_tool_conversion (self ):
712715 """Test converting function to tool via decorator."""
0 commit comments