From eeff78091490ef08ea192739ddc1f9a63f21cf31 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Fri, 13 Dec 2024 10:48:35 -0500 Subject: [PATCH] fix tests --- .../tests/integration_tests/test_parent_document.py | 11 +++++------ .../tests/integration_tests/test_retrievers.py | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libs/mongodb/tests/integration_tests/test_parent_document.py b/libs/mongodb/tests/integration_tests/test_parent_document.py index 444c06d..afd01d2 100644 --- a/libs/mongodb/tests/integration_tests/test_parent_document.py +++ b/libs/mongodb/tests/integration_tests/test_parent_document.py @@ -32,13 +32,12 @@ def embedding_model() -> Embeddings: from langchain_openai import OpenAIEmbeddings - try: - return OpenAIEmbeddings( - openai_api_key=os.environ["OPENAI_API_KEY"], # type: ignore # noqa - model="text-embedding-3-small", - ) - except Exception: + if not os.environ.get("OPENAI_API_KEY"): return ConsistentFakeEmbeddings(DIMENSIONS) + return OpenAIEmbeddings( + openai_api_key=os.environ["OPENAI_API_KEY"], # type: ignore # noqa + model="text-embedding-3-small", + ) def test_1clxn_retriever( diff --git a/libs/mongodb/tests/integration_tests/test_retrievers.py b/libs/mongodb/tests/integration_tests/test_retrievers.py index 6406b01..fa3b79c 100644 --- a/libs/mongodb/tests/integration_tests/test_retrievers.py +++ b/libs/mongodb/tests/integration_tests/test_retrievers.py @@ -47,8 +47,8 @@ def example_documents() -> List[Document]: def embedding_openai() -> Embeddings: from langchain_openai import OpenAIEmbeddings - if os.environ.get("OPENAI_API_KEY") is None: - pytest.skip("test_retrievers expects OPENAI_API_KEY in os.environ") + if not os.environ.get("OPENAI_API_KEY"): + pytest.skip("test_retrievers expects OPENAI_API_KEY in os.environ") from langchain_openai import OpenAIEmbeddings