"""Tests for data utility tools."""
import pytest
from fastmcp.client import Client
async def test_generate_uuid(client: Client):
"""Test uuid tool generates valid UUID."""
result = await client.call_tool("generate_uuid", {})
uuid_str = result.data
assert len(uuid_str) == 36
assert uuid_str[14] == "4" # Version 4
async def test_timestamp_iso(client: Client):
"""Test timestamp tool with ISO format."""
result = await client.call_tool("timestamp", {"format": "iso"})
assert "T" in result.data
assert "+" in result.data or "Z" in result.data
async def test_timestamp_unix(client: Client):
"""Test timestamp tool with Unix format."""
result = await client.call_tool("timestamp", {"format": "unix"})
assert result.data.isdigit()
assert int(result.data) > 1700000000
async def test_timestamp_default(client: Client):
"""Test timestamp tool defaults to ISO format."""
result = await client.call_tool("timestamp", {})
assert "T" in result.data
async def test_base64_encode(client: Client):
"""Test base64_encode tool."""
result = await client.call_tool("base64_encode", {"data": "hello world"})
assert result.data == "aGVsbG8gd29ybGQ="
async def test_base64_decode(client: Client):
"""Test base64_decode tool."""
result = await client.call_tool("base64_decode", {"data": "aGVsbG8gd29ybGQ="})
assert result.data == "hello world"
async def test_base64_decode_invalid(client: Client):
"""Test base64_decode tool with invalid input."""
with pytest.raises(Exception) as exc_info:
await client.call_tool("base64_decode", {"data": "not-valid-base64!!!"})
assert "Invalid base64" in str(exc_info.value)