fix tests

This commit is contained in:
David Soria Parra
2025-01-27 14:36:48 +00:00
parent 91840fd9c0
commit 43a30c1d00

View File

@@ -521,11 +521,11 @@ class TestContextInjection:
"""Test that context logging methods work.""" """Test that context logging methods work."""
mcp = FastMCP() mcp = FastMCP()
def logging_tool(msg: str, ctx: Context) -> str: async def logging_tool(msg: str, ctx: Context) -> str:
ctx.debug("Debug message") await ctx.debug("Debug message")
ctx.info("Info message") await ctx.info("Info message")
ctx.warning("Warning message") await ctx.warning("Warning message")
ctx.error("Error message") await ctx.error("Error message")
return f"Logged messages for {msg}" return f"Logged messages for {msg}"
mcp.add_tool(logging_tool) mcp.add_tool(logging_tool)
@@ -563,8 +563,8 @@ class TestContextInjection:
@mcp.tool() @mcp.tool()
async def tool_with_resource(ctx: Context) -> str: async def tool_with_resource(ctx: Context) -> str:
data = await ctx.read_resource("test://data") data, mime_type = await ctx.read_resource("test://data")
return f"Read resource: {data}" return f"Read resource: {data} with mime type {mime_type}"
async with client_session(mcp._mcp_server) as client: async with client_session(mcp._mcp_server) as client:
result = await client.call_tool("tool_with_resource", {}) result = await client.call_tool("tool_with_resource", {})