6a3c142bfa
Removed 18 unused 'from src import models' imports. Migrated the explicit sub-imports: - 'from src.models import PROVIDERS' -> 'from src.ai_client import PROVIDERS' (test_minimax_provider x2, test_deepseek_infra) - 'from src.models import Metadata' -> 'from src.type_aliases import Metadata' (test_project_manager_tracks, test_track_state_persistence, test_track_state_schema) Kept the 2 'import src.models as models' in test_provider_curation + test_providers_source_of_truth (they verify the backward-compat shim still re-exports PROVIDERS) and the 2 self-tests (test_models_no_top_level_pydantic + test_models_no_top_level_tomli_w) that exercise the shim's no-leak invariants.
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import os
|
|
import json
|
|
import pytest
|
|
|
|
from src.mcp_client import MCPServerConfig, MCPConfiguration, load_mcp_config
|
|
def test_mcp_server_config_to_from_dict():
|
|
data = {
|
|
"command": "node",
|
|
"args": ["server.js"],
|
|
"auto_start": True
|
|
}
|
|
cfg = MCPServerConfig.from_dict("test-server", data)
|
|
assert cfg.name == "test-server"
|
|
assert cfg.command == "node"
|
|
assert cfg.args == ["server.js"]
|
|
assert cfg.auto_start is True
|
|
|
|
assert cfg.to_dict() == data
|
|
|
|
def test_mcp_configuration_to_from_dict():
|
|
data = {
|
|
"mcpServers": {
|
|
"server1": {
|
|
"command": "python",
|
|
"args": ["-m", "mcp_server"],
|
|
"auto_start": False
|
|
},
|
|
"server2": {
|
|
"url": "http://localhost:8080/sse",
|
|
"auto_start": True
|
|
}
|
|
}
|
|
}
|
|
cfg = MCPConfiguration.from_dict(data)
|
|
assert len(cfg.mcpServers) == 2
|
|
assert cfg.mcpServers["server1"].command == "python"
|
|
assert cfg.mcpServers["server2"].url == "http://localhost:8080/sse"
|
|
assert cfg.to_dict() == data
|
|
|
|
def test_load_mcp_config(tmp_path):
|
|
config_file = tmp_path / "mcp_config.json"
|
|
data = {
|
|
"mcpServers": {
|
|
"test": {"command": "echo", "args": ["hello"]}
|
|
}
|
|
}
|
|
config_file.write_text(json.dumps(data))
|
|
|
|
# We'll need a way to load from a specific path
|
|
# Maybe load_mcp_config(path)
|
|
cfg = load_mcp_config(str(config_file))
|
|
assert "test" in cfg.mcpServers
|
|
assert cfg.mcpServers["test"].command == "echo"
|