Skip to main content
Glama
test_errors.py1.54 kB
"""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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bugffet/mcpbin'

If you have feedback or need assistance with the MCP directory API, please join our Discord server