From 7cbdaf74345e5ad110f625cb379e937885a8b074 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Tue, 28 May 2024 22:00:24 +0200 Subject: [PATCH] add test --- .../mongodb_atlas/tests/test_document_store.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/integrations/mongodb_atlas/tests/test_document_store.py b/integrations/mongodb_atlas/tests/test_document_store.py index 89810ec8b..a94227b93 100644 --- a/integrations/mongodb_atlas/tests/test_document_store.py +++ b/integrations/mongodb_atlas/tests/test_document_store.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 import os from uuid import uuid4 +from unittest.mock import patch import pytest from haystack.dataclasses.document import ByteStream, Document @@ -16,13 +17,23 @@ from pymongo.driver_info import DriverInfo +@patch("haystack_integrations.document_stores.mongodb_atlas.document_store.MongoClient") +def test_init_is_lazy(_mock_client): + MongoDBAtlasDocumentStore( + mongo_connection_string=Secret.from_token("test"), + database_name="database_name", + collection_name="collection_name", + vector_search_index="cosine_index", + ) + _mock_client.assert_not_called() + + @pytest.mark.skipif( "MONGO_CONNECTION_STRING" not in os.environ, reason="No MongoDB Atlas connection string provided", ) @pytest.mark.integration class TestDocumentStore(DocumentStoreBaseTests): - @pytest.fixture def document_store(self): database_name = "haystack_integration_test"