import unittest
from slack_bot.tools.registry import TOOLS_SCHEMA, TOOL_FUNCTIONS

class TestToolRegistry(unittest.TestCase):
    def test_schema_matches_functions(self):
        """Verify every tool in schema has a corresponding function."""
        schema_names = {t["function"]["name"] for t in TOOLS_SCHEMA}
        function_names = set(TOOL_FUNCTIONS.keys())
        
        # Check for missing implementations
        missing_impl = schema_names - function_names
        self.assertEqual(len(missing_impl), 0, f"Tools defined in schema but missing implementation: {missing_impl}")
        
        # Check for extra implementations (optional, but good for cleanup)
        extra_impl = function_names - schema_names
        self.assertEqual(len(extra_impl), 0, f"Functions implemented but not in schema: {extra_impl}")

    def test_functions_are_callable(self):
        """Verify all registered functions are callable."""
        for name, func in TOOL_FUNCTIONS.items():
            self.assertTrue(callable(func), f"Tool {name} is not callable")

if __name__ == '__main__':
    unittest.main()
