async def test_uc_function_to_crewai_tool(uc_client):
    """Test conversion of a UC function to a CrewaAI tool."""
    mock_function_info = generate_function_info()
    with (
        mock.patch(
            "unitycatalog.ai.core.client.UnitycatalogFunctionClient.get_function",
            return_value=mock_function_info,
        ),
        mock.patch(
            "unitycatalog.ai.core.client.UnitycatalogFunctionClient.execute_function",
            return_value=FunctionExecutionResult(format="SCALAR", value="some_string"),
        ),
    ):
        tool = UCFunctionToolkit.uc_function_to_crewai_tool(
            function_name="catalog.schema.test", client=uc_client
        )
        result = json.loads(tool.fn(x="some_string"))["value"]
        assert result == "some_string"

        # Check defaults for parameters not defined by UC
        assert tool.cache_function(1, {1: 1})
        assert not tool.result_as_answer
        assert not tool.description_updated
Test conversion of a UC function to a CrewaAI tool.
ai/integrations/crewai/tests/test_crewai_toolkit_oss.py