forked from mistralai/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_list_models.py
More file actions
40 lines (31 loc) · 1.1 KB
/
test_list_models.py
File metadata and controls
40 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import unittest.mock as mock
import pytest
from mistralai.client import MistralClient
from mistralai.models.models import ModelList
from .utils import mock_list_models_response_payload, mock_response
@pytest.fixture()
def client():
client = MistralClient()
client._client = mock.MagicMock()
return client
class TestListModels:
def test_list_models(self, client):
client._client.request.return_value = mock_response(
200,
mock_list_models_response_payload(),
)
result = client.list_models()
client._client.request.assert_called_once_with(
"get",
"https://api.mistral.ai/v1/models",
headers={
"User-Agent": f"mistral-client-python/{client._version}",
"Accept": "application/json",
"Authorization": "Bearer None",
"Content-Type": "application/json",
},
json={},
)
assert isinstance(result, ModelList), "Should return an ModelList"
assert len(result.data) == 4
assert result.object == "list"