Skip to content

Commit

Permalink
update mistral tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashraq1455 committed Mar 14, 2024
1 parent bbf717a commit 19d54ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions tests/unit/encoders/test_mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_mistral_encoder_import_errors(self):
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)
Expand Down
20 changes: 11 additions & 9 deletions tests/unit/llms/test_llm_mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from semantic_router.llms import MistralAILLM
from semantic_router.schema import Message

from unittest.mock import patch


@pytest.fixture
def mistralai_llm(mocker):
Expand All @@ -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"
Expand Down

0 comments on commit 19d54ee

Please sign in to comment.