From 6cc5679e9487a4be923fedd3a0b5c2e0e740f69f Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Mon, 22 Jan 2024 17:27:59 +0100 Subject: [PATCH] leftover --- .../pinecone/tests/test_document_store.py | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/integrations/pinecone/tests/test_document_store.py b/integrations/pinecone/tests/test_document_store.py index 6da66aa5c..a856cde86 100644 --- a/integrations/pinecone/tests/test_document_store.py +++ b/integrations/pinecone/tests/test_document_store.py @@ -48,6 +48,31 @@ def test_init_api_key_in_environment_variable(mock_pinecone, monkeypatch): mock_pinecone.init.assert_called_with(api_key="fake-api-key", environment="gcp-starter") +@patch("haystack_integrations.document_stores.pinecone.document_store.pinecone") +def test_to_dict(mock_pinecone): + mock_pinecone.Index.return_value.describe_index_stats.return_value = {"dimension": 30} + document_store = PineconeDocumentStore( + api_key="fake-api-key", + environment="gcp-starter", + index="my_index", + namespace="test", + batch_size=50, + dimension=30, + metric="euclidean", + ) + assert document_store.to_dict() == { + "type": "haystack_integrations.document_stores.pinecone.document_store.PineconeDocumentStore", + "init_parameters": { + "environment": "gcp-starter", + "index": "my_index", + "dimension": 30, + "namespace": "test", + "batch_size": 50, + "metric": "euclidean", + }, + } + + @pytest.mark.integration class TestDocumentStore(CountDocumentsTest, DeleteDocumentsTest, WriteDocumentsTest): def test_write_documents(self, document_store: PineconeDocumentStore): @@ -72,30 +97,6 @@ def test_init_fails_wo_api_key(self, monkeypatch): index="my_index", ) - @patch("pinecone_haystack.document_store.pinecone") - def test_to_dict(self, mock_pinecone): - mock_pinecone.Index.return_value.describe_index_stats.return_value = {"dimension": 30} - document_store = PineconeDocumentStore( - api_key="fake-api-key", - environment="gcp-starter", - index="my_index", - namespace="test", - batch_size=50, - dimension=30, - metric="euclidean", - ) - assert document_store.to_dict() == { - "type": "pinecone_haystack.document_store.PineconeDocumentStore", - "init_parameters": { - "environment": "gcp-starter", - "index": "my_index", - "dimension": 30, - "namespace": "test", - "batch_size": 50, - "metric": "euclidean", - }, - } - def test_embedding_retrieval(self, document_store: PineconeDocumentStore): query_embedding = [0.1] * 768 most_similar_embedding = [0.8] * 768