import pytest
import sys
import os
from unittest.mock import MagicMock, patch

# Ensure project root is in path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

from ai_client import set_agent_tools, _build_anthropic_tools

def test_set_agent_tools():
    # Correct usage: pass a dict
    agent_tools = {"read_file": True, "list_directory": False}
    set_agent_tools(agent_tools)

def test_build_anthropic_tools_conversion():
    # _build_anthropic_tools takes no arguments and uses the global _agent_tools
    # We set a tool to True and check if it appears in the output
    set_agent_tools({"read_file": True})
    anthropic_tools = _build_anthropic_tools()
    tool_names = [t["name"] for t in anthropic_tools]
    assert "read_file" in tool_names
