avoid importing the weaviate client directly (#4945)

This commit is contained in:
Massimiliano Pippi 2023-05-18 16:08:53 +02:00 committed by GitHub
parent 1f3debfd74
commit 58acef77c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ import numpy as np
from haystack.document_stores.weaviate import WeaviateDocumentStore
from haystack.schema import Document
from haystack.testing import DocumentStoreBaseTestAbstract
from haystack.document_stores import weaviate
embedding_dim = 768
@ -64,17 +63,10 @@ class TestWeaviateDocumentStore(DocumentStoreBaseTestAbstract):
"""
This fixture provides an instance of the WeaviateDocumentStore equipped with a mocked Weaviate client.
"""
class DSMock(WeaviateDocumentStore):
pass
mocked_client = mock.MagicMock()
mocked_client.Client().is_ready.return_value = True
mocked_client.Client().schema.contains.return_value = False
weaviate.client = mocked_client
mocked_ds = DSMock()
return mocked_ds
with mock.patch("haystack.document_stores.weaviate.client") as mocked_client:
mocked_client.Client().is_ready.return_value = True
mocked_client.Client().schema.contains.return_value = False
yield WeaviateDocumentStore()
@pytest.mark.skip(reason="Weaviate does not support labels")
@pytest.mark.integration