"""Tests for error simulation tools."""
import pytest
from fastmcp.client import Client
async def test_status_error(client: Client):
"""Test status_error tool raises error with message."""
with pytest.raises(Exception) as exc_info:
await client.call_tool("status_error", {"message": "Something went wrong"})
assert "Something went wrong" in str(exc_info.value)
async def test_status_error_with_code(client: Client):
"""Test status_error tool raises error with code."""
with pytest.raises(Exception) as exc_info:
await client.call_tool("status_error", {"message": "Not found", "code": "NOT_FOUND"})
assert "NOT_FOUND" in str(exc_info.value)
assert "Not found" in str(exc_info.value)
async def test_random_error_with_seed_success(client: Client):
"""Test random_error with seed for deterministic success."""
result = await client.call_tool("random_error", {"failure_rate": 0.5, "seed": 42})
assert result.data["success"] is True
async def test_random_error_with_seed_failure(client: Client):
"""Test random_error with seed for deterministic failure."""
with pytest.raises(Exception) as exc_info:
await client.call_tool("random_error", {"failure_rate": 0.5, "seed": 1})
assert "Random failure" in str(exc_info.value)
async def test_random_error_zero_rate(client: Client):
"""Test random_error with 0% failure rate always succeeds."""
result = await client.call_tool("random_error", {"failure_rate": 0.0})
assert result.data["success"] is True