# tests/test_toolset.py
import pytest

# Only run if pydantic-ai is installed
pydantic_ai = pytest.importorskip("pydantic_ai")

from agentsh_secure_sandbox.toolset.pydantic_ai import SecureSandboxToolset  # noqa: E402
from unittest.mock import MagicMock  # noqa: E402


async def test_toolset_requires_context():
    adapter = MagicMock()
    toolset = SecureSandboxToolset(adapter)
    with pytest.raises(RuntimeError, match="not initialized"):
        _ = toolset.sandbox


async def test_toolset_has_three_tools():
    """Toolset should define run_command, write_file, read_file."""
    defs = SecureSandboxToolset._TOOL_DEFS
    assert "run_command" in defs
    assert "write_file" in defs
    assert "read_file" in defs


async def test_toolset_id():
    adapter = MagicMock()
    toolset = SecureSandboxToolset(adapter, toolset_id="custom-id")
    assert toolset.id == "custom-id"
