Skip to content

Commit 9ffddf8

Browse files
committed
fix tests
1 parent 6d9e2a5 commit 9ffddf8

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tests/test_embeddings.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
from unittest.mock import patch
3+
14
import pytest
25
from dirty_equals import IsList
36

@@ -22,14 +25,23 @@
2225
@pytest.mark.skipif(not openai_imports_successful, reason='OpenAI not installed')
2326
class TestOpenAI:
2427
async def test_infer_model(self, openai_api_key: str):
25-
model = infer_model('openai:text-embedding-3-small')
28+
with patch.dict(os.environ, {'OPENAI_API_KEY': openai_api_key}):
29+
model = infer_model('openai:text-embedding-3-small')
2630
assert isinstance(model, OpenAIEmbeddingModel)
2731
assert model.model_name == 'text-embedding-3-small'
2832
assert model.system == 'openai'
2933
assert model.base_url == 'https://api.openai.com/v1/'
3034

3135
async def test_infer_model_azure(self, openai_api_key: str):
32-
model = infer_model('azure:text-embedding-3-small')
36+
with patch.dict(
37+
os.environ,
38+
{
39+
'AZURE_OPENAI_API_KEY': 'azure-openai-api-key',
40+
'AZURE_OPENAI_ENDPOINT': 'https://project-id.openai.azure.com/',
41+
'OPENAI_API_VERSION': '2023-03-15-preview',
42+
},
43+
):
44+
model = infer_model('azure:text-embedding-3-small')
3345
assert isinstance(model, OpenAIEmbeddingModel)
3446
assert model.model_name == 'text-embedding-3-small'
3547
assert model.system == 'azure'
@@ -55,7 +67,8 @@ async def test_bulk(self, openai_api_key: str):
5567
@pytest.mark.skipif(not cohere_imports_successful, reason='Cohere not installed')
5668
class TestCohere:
5769
async def test_infer_model(self, co_api_key: str):
58-
model = infer_model('cohere:embed-v4.0')
70+
with patch.dict(os.environ, {'CO_API_KEY': co_api_key}):
71+
model = infer_model('cohere:embed-v4.0')
5972
assert isinstance(model, CohereEmbeddingModel)
6073
assert model.model_name == 'embed-v4.0'
6174
assert model.system == 'cohere'

0 commit comments

Comments
 (0)