File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from unittest .mock import AsyncMock , MagicMock , patch
22
33import pytest
4+ from chromadb .errors import NotFoundError
45from mcp import McpError
56
67from vectorcode .cli_utils import Config
@@ -182,3 +183,25 @@ async def test_mcp_server():
182183 await mcp_server ()
183184
184185 assert mock_add_tool .call_count == 2
186+
187+
188+ @pytest .mark .asyncio
189+ async def test_mcp_server_no_default_collection ():
190+ with (
191+ patch (
192+ "vectorcode.mcp_main.find_project_config_dir"
193+ ) as mock_find_project_config_dir ,
194+ patch ("vectorcode.mcp_main.load_config_file" ) as mock_load_config_file ,
195+ patch ("vectorcode.mcp_main.get_client" ) as mock_get_client ,
196+ patch ("vectorcode.mcp_main.get_collection" ) as mock_get_collection ,
197+ patch ("mcp.server.fastmcp.FastMCP.add_tool" ) as mock_add_tool ,
198+ ):
199+ mock_find_project_config_dir .return_value = "/path/to/config"
200+ mock_load_config_file .return_value = Config (project_root = "/path/to/project" )
201+ mock_client = AsyncMock ()
202+ mock_get_client .return_value = mock_client
203+ mock_get_collection .side_effect = NotFoundError ()
204+
205+ await mcp_server ()
206+
207+ assert mock_add_tool .call_count == 2
You can’t perform that action at this time.
0 commit comments