fix tests
This commit is contained in:
parent
680afeeed6
commit
44e1abb7f1
3 changed files with 15 additions and 5 deletions
|
|
@ -77,6 +77,7 @@ target-version = "py310"
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
"__init__.py" = ["F401"]
|
"__init__.py" = ["F401"]
|
||||||
|
"tests/server/fastmcp/test_func_metadata.py" = ["E501"]
|
||||||
|
|
||||||
[tool.uv.workspace]
|
[tool.uv.workspace]
|
||||||
members = ["examples/servers/*"]
|
members = ["examples/servers/*"]
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ def test_complex_function_json_schema():
|
||||||
},
|
},
|
||||||
"field_with_default_via_field_annotation_before_nondefault_arg": {
|
"field_with_default_via_field_annotation_before_nondefault_arg": {
|
||||||
"default": 1,
|
"default": 1,
|
||||||
"title": "Field With Default Via Field Annotation Before Arg",
|
"title": "Field With Default Via Field Annotation Before Nondefault Arg",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
},
|
},
|
||||||
"unannotated": {"title": "unannotated", "type": "string"},
|
"unannotated": {"title": "unannotated", "type": "string"},
|
||||||
|
|
@ -319,7 +319,7 @@ def test_complex_function_json_schema():
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
"my_model_a_with_default": {
|
"my_model_a_with_default": {
|
||||||
"allOf": [{"$ref": "#/$defs/SomeInputModelA"}],
|
"$ref": "#/$defs/SomeInputModelA",
|
||||||
"default": {},
|
"default": {},
|
||||||
},
|
},
|
||||||
"an_int_with_default": {
|
"an_int_with_default": {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import pytest
|
||||||
from mcp.shared.memory import (
|
from mcp.shared.memory import (
|
||||||
create_connected_server_and_client_session as client_session,
|
create_connected_server_and_client_session as client_session,
|
||||||
)
|
)
|
||||||
from mcp.types import TextContent
|
from mcp.types import TextContent, TextResourceContents
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
|
|
@ -41,12 +41,19 @@ async def test_complex_inputs():
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.anyio
|
@pytest.mark.anyio
|
||||||
async def test_desktop():
|
async def test_desktop(monkeypatch):
|
||||||
"""Test the desktop server"""
|
"""Test the desktop server"""
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from pydantic import AnyUrl
|
from pydantic import AnyUrl
|
||||||
|
|
||||||
from examples.fastmcp.desktop import mcp
|
from examples.fastmcp.desktop import mcp
|
||||||
|
|
||||||
|
# Mock desktop directory listing
|
||||||
|
mock_files = [Path("/fake/path/file1.txt"), Path("/fake/path/file2.txt")]
|
||||||
|
monkeypatch.setattr(Path, "iterdir", lambda self: mock_files)
|
||||||
|
monkeypatch.setattr(Path, "home", lambda: Path("/fake/home"))
|
||||||
|
|
||||||
async with client_session(mcp._mcp_server) as client:
|
async with client_session(mcp._mcp_server) as client:
|
||||||
# Test the add function
|
# Test the add function
|
||||||
result = await client.call_tool("add", {"a": 1, "b": 2})
|
result = await client.call_tool("add", {"a": 1, "b": 2})
|
||||||
|
|
@ -59,5 +66,7 @@ async def test_desktop():
|
||||||
result = await client.read_resource(AnyUrl("dir://desktop"))
|
result = await client.read_resource(AnyUrl("dir://desktop"))
|
||||||
assert len(result.contents) == 1
|
assert len(result.contents) == 1
|
||||||
content = result.contents[0]
|
content = result.contents[0]
|
||||||
assert isinstance(content, TextContent)
|
assert isinstance(content, TextResourceContents)
|
||||||
assert isinstance(content.text, str)
|
assert isinstance(content.text, str)
|
||||||
|
assert "/fake/path/file1.txt" in content.text
|
||||||
|
assert "/fake/path/file2.txt" in content.text
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue