diff --git a/libs/kotaemon/tests/test_embedding_models.py b/libs/kotaemon/tests/test_embedding_models.py index 07e950d5..5d0327ad 100644 --- a/libs/kotaemon/tests/test_embedding_models.py +++ b/libs/kotaemon/tests/test_embedding_models.py @@ -1,6 +1,6 @@ import json from pathlib import Path -from unittest.mock import patch +from unittest.mock import Mock, patch from openai.types.create_embedding_response import CreateEmbeddingResponse @@ -159,18 +159,14 @@ def test_fastembed_embeddings(): assert_embedding_result(output) +voyage_output_mock = Mock() +voyage_output_mock.embeddings = [[1.0, 2.1, 3.2]] + + @skip_when_voyageai_not_installed -@patch( - "voyageai.Client.embed", - side_effect=lambda *args, **kwargs: [[1.0, 2.1, 3.2]], -) -@patch( - "voyageai.AsyncClient.embed", - side_effect=lambda *args, **kwargs: [[1.0, 2.1, 3.2]], -) -def test_voyageai_embeddings(): - model = VoyageAIEmbeddings() +@patch("voyageai.Client.embed", return_value=voyage_output_mock) +@patch("voyageai.AsyncClient.embed", return_value=voyage_output_mock) +def test_voyageai_embeddings(sync_call, async_call): + model = VoyageAIEmbeddings(api_key="test") output = model("Hello, world!") - assert isinstance(output, list) and all( - isinstance(doc, DocumentWithEmbedding) for doc in output - ) + assert all(isinstance(doc, DocumentWithEmbedding) for doc in output)