From 19d54ee605ca7bd8008bcc9425170821f0cfcc2d Mon Sep 17 00:00:00 2001 From: Ismail Ashraq <issey1455@gmail.com> Date: Thu, 14 Mar 2024 23:15:36 +0500 Subject: [PATCH] update mistral tests --- tests/unit/encoders/test_mistral.py | 1 + tests/unit/llms/test_llm_mistral.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/unit/encoders/test_mistral.py b/tests/unit/encoders/test_mistral.py index f8b52338..f36f5037 100644 --- a/tests/unit/encoders/test_mistral.py +++ b/tests/unit/encoders/test_mistral.py @@ -28,6 +28,7 @@ class TestMistralEncoder: def test_mistralai_encoder_init_success(self, mocker): encoder = MistralEncoder(mistralai_api_key="test_api_key") assert encoder._client is not None + assert encoder._mistralai is not None def test_mistralai_encoder_init_no_api_key(self, mocker): mocker.patch("os.getenv", return_value=None) diff --git a/tests/unit/llms/test_llm_mistral.py b/tests/unit/llms/test_llm_mistral.py index 420c9861..d73406e7 100644 --- a/tests/unit/llms/test_llm_mistral.py +++ b/tests/unit/llms/test_llm_mistral.py @@ -3,6 +3,8 @@ import pytest from semantic_router.llms import MistralAILLM from semantic_router.schema import Message +from unittest.mock import patch + @pytest.fixture def mistralai_llm(mocker): @@ -11,16 +13,16 @@ def mistralai_llm(mocker): class TestMistralAILLM: - # def test_mistral_llm_import_errors(self): - # with patch.dict("sys.modules", {"mistralai": None}): - # with pytest.raises(ImportError) as error: - # MistralAILLM() + def test_mistral_llm_import_errors(self): + with patch.dict("sys.modules", {"mistralai": None}): + with pytest.raises(ImportError) as error: + MistralAILLM() - # assert ( - # "Please install MistralAI to use MistralAI LLM. " - # "You can install it with: " - # "`pip install 'semantic-router[mistralai]'`" in str(error.value) - # ) + assert ( + "Please install MistralAI to use MistralAI LLM. " + "You can install it with: " + "`pip install 'semantic-router[mistralai]'`" in str(error.value) + ) def test_mistralai_llm_init_with_api_key(self, mistralai_llm): assert mistralai_llm._client is not None, "Client should be initialized" -- GitLab