mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-19 20:14:17 +02:00
Add test
This commit is contained in:
parent
34aa69d63e
commit
82ac176fdf
1 changed files with 30 additions and 1 deletions
|
|
@ -14,7 +14,12 @@ from pydantic.networks import AnyUrl
|
|||
|
||||
from fastmcp import FastMCP
|
||||
from fastmcp.client import Client
|
||||
from fastmcp.server.openapi import FastMCPOpenAPI
|
||||
from fastmcp.server.openapi import (
|
||||
FastMCPOpenAPI,
|
||||
OpenAPIResource,
|
||||
OpenAPIResourceTemplate,
|
||||
OpenAPITool,
|
||||
)
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
|
|
@ -128,6 +133,30 @@ async def test_create_fastapi_server_classmethod(fastapi_app: FastAPI):
|
|||
assert server.name == "FastAPI App"
|
||||
|
||||
|
||||
async def test_create_openapi_server_with_timeout(
|
||||
fastapi_app: FastAPI, api_client: httpx.AsyncClient
|
||||
):
|
||||
server = FastMCPOpenAPI(
|
||||
openapi_spec=fastapi_app.openapi(),
|
||||
client=api_client,
|
||||
name="Test App",
|
||||
timeout=1.0,
|
||||
)
|
||||
assert server._timeout == 1.0
|
||||
|
||||
for tool in (await server.get_tools()).values():
|
||||
assert isinstance(tool, OpenAPITool)
|
||||
assert tool._timeout == 1.0
|
||||
|
||||
for resource in (await server.get_resources()).values():
|
||||
assert isinstance(resource, OpenAPIResource)
|
||||
assert resource._timeout == 1.0
|
||||
|
||||
for template in (await server.get_resource_templates()).values():
|
||||
assert isinstance(template, OpenAPIResourceTemplate)
|
||||
assert template._timeout == 1.0
|
||||
|
||||
|
||||
class TestTools:
|
||||
async def test_list_tools(self, fastmcp_openapi_server: FastMCPOpenAPI):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue