def test_map_tool_choice_to_anthropic():
    """Test that tool_required is correctly mapped to Anthropic's tool_choice parameter."""
    llm = Anthropic()

    # Test with tool_required=True
    tool_choice = llm._map_tool_choice_to_anthropic(
        tool_required=True, allow_parallel_tool_calls=False
    )
    assert tool_choice["type"] == "any"
    assert tool_choice["disable_parallel_tool_use"]

    # Test with tool_required=False
    tool_choice = llm._map_tool_choice_to_anthropic(
        tool_required=False, allow_parallel_tool_calls=False
    )
    assert tool_choice["type"] == "auto"
    assert tool_choice["disable_parallel_tool_use"]

    # Test with allow_parallel_tool_calls=True
    tool_choice = llm._map_tool_choice_to_anthropic(
        tool_required=True, allow_parallel_tool_calls=True
    )
    assert tool_choice["type"] == "any"
    assert not tool_choice["disable_parallel_tool_use"]
Test that tool_required is correctly mapped to Anthropic's tool_choice parameter.
llama-index-integrations/llms/llama-index-llms-anthropic/tests/test_llms_anthropic.py