Skip to content

Commit 44e1abb

Browse files
committed
fix tests
1 parent 680afee commit 44e1abb

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Diff for: pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ target-version = "py310"
7777

7878
[tool.ruff.lint.per-file-ignores]
7979
"__init__.py" = ["F401"]
80+
"tests/server/fastmcp/test_func_metadata.py" = ["E501"]
8081

8182
[tool.uv.workspace]
8283
members = ["examples/servers/*"]

Diff for: tests/server/fastmcp/test_func_metadata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def test_complex_function_json_schema():
300300
},
301301
"field_with_default_via_field_annotation_before_nondefault_arg": {
302302
"default": 1,
303-
"title": "Field With Default Via Field Annotation Before Arg",
303+
"title": "Field With Default Via Field Annotation Before Nondefault Arg",
304304
"type": "integer",
305305
},
306306
"unannotated": {"title": "unannotated", "type": "string"},
@@ -319,7 +319,7 @@ def test_complex_function_json_schema():
319319
"type": "string",
320320
},
321321
"my_model_a_with_default": {
322-
"allOf": [{"$ref": "#/$defs/SomeInputModelA"}],
322+
"$ref": "#/$defs/SomeInputModelA",
323323
"default": {},
324324
},
325325
"an_int_with_default": {

Diff for: tests/test_examples.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from mcp.shared.memory import (
66
create_connected_server_and_client_session as client_session,
77
)
8-
from mcp.types import TextContent
8+
from mcp.types import TextContent, TextResourceContents
99

1010

1111
@pytest.mark.anyio
@@ -41,12 +41,19 @@ async def test_complex_inputs():
4141

4242

4343
@pytest.mark.anyio
44-
async def test_desktop():
44+
async def test_desktop(monkeypatch):
4545
"""Test the desktop server"""
46+
from pathlib import Path
47+
4648
from pydantic import AnyUrl
4749

4850
from examples.fastmcp.desktop import mcp
4951

52+
# Mock desktop directory listing
53+
mock_files = [Path("/fake/path/file1.txt"), Path("/fake/path/file2.txt")]
54+
monkeypatch.setattr(Path, "iterdir", lambda self: mock_files)
55+
monkeypatch.setattr(Path, "home", lambda: Path("/fake/home"))
56+
5057
async with client_session(mcp._mcp_server) as client:
5158
# Test the add function
5259
result = await client.call_tool("add", {"a": 1, "b": 2})
@@ -59,5 +66,7 @@ async def test_desktop():
5966
result = await client.read_resource(AnyUrl("dir://desktop"))
6067
assert len(result.contents) == 1
6168
content = result.contents[0]
62-
assert isinstance(content, TextContent)
69+
assert isinstance(content, TextResourceContents)
6370
assert isinstance(content.text, str)
71+
assert "/fake/path/file1.txt" in content.text
72+
assert "/fake/path/file2.txt" in content.text

0 commit comments

Comments
 (0)