Spaces:
Running
Running
Jeremiah Lowin commited on
Commit ·
b90e63c
1
Parent(s): 1988304
Add validation test
Browse files- tests/cli/test_run.py +14 -0
tests/cli/test_run.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import inspect
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
import pytest
|
|
|
|
| 5 |
|
| 6 |
from fastmcp.cli.run import (
|
| 7 |
create_mcp_config_server,
|
|
@@ -126,6 +128,18 @@ class TestMCPConfig:
|
|
| 126 |
tools = await client.list_tools()
|
| 127 |
assert len(tools) == 1
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
class TestServerImport:
|
| 131 |
"""Test server import functionality using real files."""
|
|
|
|
| 1 |
import inspect
|
| 2 |
+
import json
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
import pytest
|
| 6 |
+
from pydantic import ValidationError
|
| 7 |
|
| 8 |
from fastmcp.cli.run import (
|
| 9 |
create_mcp_config_server,
|
|
|
|
| 128 |
tools = await client.list_tools()
|
| 129 |
assert len(tools) == 1
|
| 130 |
|
| 131 |
+
async def test_validate_mcp_config(self, tmp_path: Path):
|
| 132 |
+
"""Test creating a server from an MCPConfig file."""
|
| 133 |
+
|
| 134 |
+
mcp_config_path = tmp_path / "mcp_config.json"
|
| 135 |
+
|
| 136 |
+
mcp_config = {"mcpServers": {"test_server": dict(x=1, y=2)}}
|
| 137 |
+
with mcp_config_path.open("w") as f:
|
| 138 |
+
json.dump(mcp_config, f)
|
| 139 |
+
|
| 140 |
+
with pytest.raises(ValidationError, match="validation errors for MCPConfig"):
|
| 141 |
+
create_mcp_config_server(mcp_config_path)
|
| 142 |
+
|
| 143 |
|
| 144 |
class TestServerImport:
|
| 145 |
"""Test server import functionality using real files."""
|