mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 06:24:18 +02:00
Refactor tests (remove duplicate). Add test coverage for simple_echo, complex_inputs, desktop, echo.
This commit is contained in:
parent
d999c9545e
commit
3539de0c82
6 changed files with 633 additions and 535 deletions
|
|
@ -762,6 +762,10 @@ Run the test suite:
|
|||
```bash
|
||||
uv run pytest -vv
|
||||
```
|
||||
or if you want an overview of the code coverage
|
||||
```bash
|
||||
uv run pytest --cov=src --cov=examples --cov-report=html
|
||||
```
|
||||
|
||||
#### Formatting & Linting
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ def desktop() -> list[str]:
|
|||
return [str(f) for f in desktop.iterdir()]
|
||||
|
||||
|
||||
# Add a dynamic greeting resource
|
||||
@mcp.resource("greeting://{name}")
|
||||
def get_greeting(name: str) -> str:
|
||||
"""Get a personalized greeting"""
|
||||
return f"Hello, {name}!"
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
def add(a: int, b: int) -> int:
|
||||
"""Add two numbers"""
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
from fastmcp import FastMCP
|
||||
|
||||
# Create an MCP server
|
||||
mcp = FastMCP("Demo")
|
||||
|
||||
|
||||
# Add an addition tool
|
||||
@mcp.tool()
|
||||
def add(a: int, b: int) -> int:
|
||||
"""Add two numbers"""
|
||||
return a + b
|
||||
|
||||
|
||||
# Add a dynamic greeting resource
|
||||
@mcp.resource("greeting://{name}")
|
||||
def get_greeting(name: str) -> str:
|
||||
"""Get a personalized greeting"""
|
||||
return f"Hello, {name}!"
|
||||
|
|
@ -7,7 +7,7 @@ dependencies = [
|
|||
"python-dotenv>=1.1.0",
|
||||
"exceptiongroup>=1.2.2",
|
||||
"httpx>=0.28.1",
|
||||
"mcp>=1.6.0,<2.0.0",
|
||||
"mcp>=1.7.1,<2.0.0",
|
||||
"openapi-pydantic>=0.5.1",
|
||||
"rich>=13.9.4",
|
||||
"typer>=0.15.2",
|
||||
|
|
@ -47,7 +47,9 @@ dev = [
|
|||
"pyright>=1.1.389",
|
||||
"pytest>=8.3.3",
|
||||
"pytest-asyncio>=0.23.5",
|
||||
"pytest-cov>=6.1.1",
|
||||
"pytest-flakefinder",
|
||||
"pytest-report>=0.2.1",
|
||||
"pytest-xdist>=3.6.1",
|
||||
"ruff",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ class TestTools:
|
|||
assert len(tools) == 2
|
||||
|
||||
assert tools[0].model_dump() == dict(
|
||||
annotations=None,
|
||||
name="create_user_users_post",
|
||||
description=IsStr(regex=r"^Create a new user\..*$", regex_flags=re.DOTALL),
|
||||
inputSchema={
|
||||
|
|
@ -206,6 +207,7 @@ class TestTools:
|
|||
},
|
||||
)
|
||||
assert tools[1].model_dump() == dict(
|
||||
annotations=None,
|
||||
name="update_user_name_users__user_id__name_patch",
|
||||
description=IsStr(
|
||||
regex=r"^Update a user's name\..*$", regex_flags=re.DOTALL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue