2929from ..common import common
3030
3131
32- model = SentenceTransformer (' all-MiniLM-L6-v2' )
32+ model = SentenceTransformer (" all-MiniLM-L6-v2" )
3333
3434
3535@patch ("couchbase_haystack.document_stores.document_store.Cluster" )
@@ -149,7 +149,6 @@ def document_store(self):
149149 cluster .close ()
150150
151151 def assert_documents_are_equal (self , received : List [Document ], expected : List [Document ]):
152-
153152 for r in received :
154153 r .score = None
155154 r .embedding = None
@@ -192,7 +191,7 @@ def test_write_blob(self, document_store: CouchbaseSearchDocumentStore):
192191 documents = [Document (blob = bytestream )]
193192 for doc in documents :
194193 # Assuming blob_content is in bytes, decode it to string if necessary
195- embedding = model .encode (bytestream .data .decode (' utf-8' )).tolist ()
194+ embedding = model .encode (bytestream .data .decode (" utf-8" )).tolist ()
196195 doc .embedding = embedding
197196 assert document_store .write_documents (documents ) == 1
198197 retrieved_docs = document_store .filter_documents ()
@@ -283,7 +282,6 @@ class TestSearchDocumentStoreUnit:
283282 @pytest .fixture
284283 def document_store (self ):
285284 with patch ("couchbase_haystack.document_stores.document_store.Cluster" ) as mock_cb_cluster :
286-
287285 cluster = mock_cb_cluster .return_value
288286 bucket = cluster .bucket .return_value
289287 scope = bucket .scope .return_value
@@ -310,59 +308,59 @@ def test_to_dict(self, document_store: DocumentStore):
310308 serialized_store = document_store .document_store .to_dict ()
311309 # assert serialized_store["init_parameters"].pop("collection_name").startswith("test_collection_")
312310 assert serialized_store == {
313- ' type' : ' couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore' ,
314- ' init_parameters' : {
315- ' cluster_connection_string' : {' type' : ' env_var' , ' env_vars' : [' CONNECTION_STRING' ], ' strict' : True },
316- ' authenticator' : {
317- ' type' : ' couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator' ,
318- ' init_parameters' : {
319- ' username' : {' type' : ' env_var' , ' env_vars' : [' USER_NAME' ], ' strict' : True },
320- ' password' : {' type' : ' env_var' , ' env_vars' : [' PASSWORD' ], ' strict' : True },
321- ' cert_path' : None ,
311+ " type" : " couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore" ,
312+ " init_parameters" : {
313+ " cluster_connection_string" : {" type" : " env_var" , " env_vars" : [" CONNECTION_STRING" ], " strict" : True },
314+ " authenticator" : {
315+ " type" : " couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator" ,
316+ " init_parameters" : {
317+ " username" : {" type" : " env_var" , " env_vars" : [" USER_NAME" ], " strict" : True },
318+ " password" : {" type" : " env_var" , " env_vars" : [" PASSWORD" ], " strict" : True },
319+ " cert_path" : None ,
322320 },
323321 },
324- ' cluster_options' : {
325- ' type' : ' couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions' ,
326- ' init_parameters' : {' profile' : ' wan_development' },
322+ " cluster_options" : {
323+ " type" : " couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions" ,
324+ " init_parameters" : {" profile" : " wan_development" },
327325 },
328- ' bucket' : ' test_bucket' ,
329- ' scope' : ' test_scope' ,
330- ' collection' : ' test_collection' ,
331- ' vector_search_index' : ' vector_search' ,
332- ' is_global_level_index' : IS_GLOBAL_LEVEL_INDEX ,
326+ " bucket" : " test_bucket" ,
327+ " scope" : " test_scope" ,
328+ " collection" : " test_collection" ,
329+ " vector_search_index" : " vector_search" ,
330+ " is_global_level_index" : IS_GLOBAL_LEVEL_INDEX ,
333331 },
334332 }
335333
336334 def test_from_dict (self ):
337335 docstore = CouchbaseSearchDocumentStore .from_dict (
338336 {
339- ' type' : ' couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore' ,
340- ' init_parameters' : {
341- ' cluster_connection_string' : {' type' : ' env_var' , ' env_vars' : [' CONNECTION_STRING' ], ' strict' : True },
342- ' authenticator' : {
343- ' type' : ' couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator' ,
344- ' init_parameters' : {
345- ' username' : {' type' : ' env_var' , ' env_vars' : [' USER_NAME' ], ' strict' : True },
346- ' password' : {' type' : ' env_var' , ' env_vars' : [' PASSWORD' ], ' strict' : True },
347- ' cert_path' : None ,
337+ " type" : " couchbase_haystack.document_stores.document_store.CouchbaseSearchDocumentStore" ,
338+ " init_parameters" : {
339+ " cluster_connection_string" : {" type" : " env_var" , " env_vars" : [" CONNECTION_STRING" ], " strict" : True },
340+ " authenticator" : {
341+ " type" : " couchbase_haystack.document_stores.auth.CouchbasePasswordAuthenticator" ,
342+ " init_parameters" : {
343+ " username" : {" type" : " env_var" , " env_vars" : [" USER_NAME" ], " strict" : True },
344+ " password" : {" type" : " env_var" , " env_vars" : [" PASSWORD" ], " strict" : True },
345+ " cert_path" : None ,
348346 },
349347 },
350- ' cluster_options' : {
351- ' type' : ' couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions' ,
352- ' init_parameters' : {' profile' : ' wan_development' },
348+ " cluster_options" : {
349+ " type" : " couchbase_haystack.document_stores.cluster_options.CouchbaseClusterOptions" ,
350+ " init_parameters" : {" profile" : " wan_development" },
353351 },
354- ' bucket' : ' test_bucket' ,
355- ' scope' : ' test_scope' ,
356- ' collection' : ' test_collection' ,
357- ' vector_search_index' : ' vector_search' ,
358- ' is_global_level_index' : IS_GLOBAL_LEVEL_INDEX ,
352+ " bucket" : " test_bucket" ,
353+ " scope" : " test_scope" ,
354+ " collection" : " test_collection" ,
355+ " vector_search_index" : " vector_search" ,
356+ " is_global_level_index" : IS_GLOBAL_LEVEL_INDEX ,
359357 },
360358 }
361359 )
362360 assert docstore .cluster_connection_string == Secret .from_env_var ("CONNECTION_STRING" )
363- assert docstore .bucket_name == ' test_bucket'
364- assert docstore .scope_name == ' test_scope'
365- assert docstore .collection_name == ' test_collection'
361+ assert docstore .bucket_name == " test_bucket"
362+ assert docstore .scope_name == " test_scope"
363+ assert docstore .collection_name == " test_collection"
366364 assert docstore .vector_search_index == "vector_search"
367365 assert docstore .cluster_options ["profile" ] == KnownConfigProfiles .WanDevelopment
368366 assert docstore .is_global_level_index == IS_GLOBAL_LEVEL_INDEX
@@ -383,6 +381,6 @@ def test_init_default(self, document_store: DocumentStore, monkeypatch):
383381 if IS_GLOBAL_LEVEL_INDEX :
384382 document_store .cluster .search .assert_called_once ()
385383 else :
386- document_store .cluster .bucket .return_value .scope .assert_called_once_with (' test_scope' )
384+ document_store .cluster .bucket .return_value .scope .assert_called_once_with (" test_scope" )
387385 document_store .cluster .bucket .return_value .scope .return_value .search .assert_called_once ()
388386 assert doc == [Document (id = "1a" , content = "text" , score = 1 )]
0 commit comments