@@ -509,15 +509,19 @@ async def test_wait_for_server_timeout():
509509
510510@pytest .mark .asyncio
511511async def test_client_manager_get_client ():
512- config = Config (db_url = "https://test_host:1234" , db_path = "test_db" )
512+ config = Config (
513+ db_url = "https://test_host:1234" , db_path = "test_db" , project_root = "test_proj"
514+ )
513515 config1 = Config (
514516 db_url = "http://test_host1:1234" ,
515517 db_path = "test_db" ,
518+ project_root = "test_proj1" ,
516519 db_settings = {"anonymized_telemetry" : True },
517520 )
518521 config1_alt = Config (
519522 db_url = "http://test_host1:1234" ,
520523 db_path = "test_db" ,
524+ project_root = "test_proj1" ,
521525 db_settings = {"anonymized_telemetry" : True , "other_setting" : "value" },
522526 )
523527 # Patch chromadb.AsyncHttpClient to avoid actual network calls
@@ -580,6 +584,42 @@ async def test_client_manager_get_client():
580584 assert id (client1_alt ) == id (client1 )
581585
582586
587+ @pytest .mark .asyncio
588+ async def test_client_manager_list_server_processes ():
589+ async def _try_server (url ):
590+ return "127.0.0.1" in url or "localhost" in url
591+
592+ async def _start_server (cfg ):
593+ return AsyncMock ()
594+
595+ with (
596+ tempfile .TemporaryDirectory () as temp_dir ,
597+ patch ("vectorcode.common.start_server" , side_effect = _start_server ),
598+ patch ("vectorcode.common.try_server" , side_effect = _try_server ),
599+ ):
600+ db_path = os .path .join (temp_dir , "db" )
601+ os .makedirs (db_path , exist_ok = True )
602+
603+ ClientManager ._create_client = AsyncMock ()
604+ async with ClientManager ().get_client (
605+ Config (
606+ db_url = "http://test_host:8001" ,
607+ project_root = "proj1" ,
608+ db_path = db_path ,
609+ )
610+ ):
611+ print (ClientManager ().get_processes ())
612+ async with ClientManager ().get_client (
613+ Config (
614+ db_url = "http://test_host:8002" ,
615+ project_root = "proj2" ,
616+ db_path = db_path ,
617+ )
618+ ):
619+ pass
620+ assert len (ClientManager ().get_processes ()) == 2
621+
622+
583623@pytest .mark .asyncio
584624async def test_client_manager_kill_servers ():
585625 manager = ClientManager ()
@@ -596,5 +636,6 @@ async def _try_server(url):
596636 manager ._create_client = AsyncMock (return_value = AsyncMock ())
597637 async with manager .get_client (Config (db_url = "http://test_host:1081" )):
598638 pass
639+ assert len (manager .get_processes ()) == 1
599640 await manager .kill_servers ()
600641 mock_process .terminate .assert_called_once ()
0 commit comments