@@ -327,7 +327,19 @@ async def test_get_collection():
327327 ),
328328 "created-by" : "VectorCode" ,
329329 }
330- mock_client .get_or_create_collection .return_value = mock_collection
330+
331+ async def mock_get_or_create_collection (
332+ self ,
333+ name = None ,
334+ configuration = None ,
335+ metadata = None ,
336+ embedding_function = None ,
337+ data_loader = None ,
338+ ):
339+ mock_collection .metadata .update (metadata or {})
340+ return mock_collection
341+
342+ mock_client .get_or_create_collection .side_effect = mock_get_or_create_collection
331343 MockAsyncHttpClient .return_value = mock_client
332344
333345 collection = await get_collection (mock_client , config , make_if_missing = True )
@@ -336,6 +348,7 @@ async def test_get_collection():
336348 "USER" , os .environ .get ("USERNAME" , "DEFAULT_USER" )
337349 )
338350 assert collection .metadata ["created-by" ] == "VectorCode"
351+ assert collection .metadata ["hnsw:M" ] == 64
339352 mock_client .get_or_create_collection .assert_called_once ()
340353 mock_client .get_collection .side_effect = None
341354
@@ -361,7 +374,7 @@ async def test_get_collection_hnsw():
361374 embedding_function = "SentenceTransformerEmbeddingFunction" ,
362375 embedding_params = {},
363376 project_root = "/test_project" ,
364- hnsw = {"ef_construction" : 200 , "m " : 32 },
377+ hnsw = {"ef_construction" : 200 , "M " : 32 },
365378 )
366379
367380 with patch ("chromadb.AsyncHttpClient" ) as MockAsyncHttpClient :
@@ -374,7 +387,7 @@ async def test_get_collection_hnsw():
374387 ),
375388 "created-by" : "VectorCode" ,
376389 "hnsw:ef_construction" : 200 ,
377- "hnsw:m " : 32 ,
390+ "hnsw:M " : 32 ,
378391 "embedding_function" : "SentenceTransformerEmbeddingFunction" ,
379392 "path" : "/test_project" ,
380393 }
@@ -394,7 +407,7 @@ async def test_get_collection_hnsw():
394407 )
395408 assert collection .metadata ["created-by" ] == "VectorCode"
396409 assert collection .metadata ["hnsw:ef_construction" ] == 200
397- assert collection .metadata ["hnsw:m " ] == 32
410+ assert collection .metadata ["hnsw:M " ] == 32
398411 mock_client .get_or_create_collection .assert_called_once ()
399412 assert (
400413 mock_client .get_or_create_collection .call_args .kwargs ["metadata" ]
0 commit comments