-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import openai | ||
from openai import OpenAI | ||
from openai import AsyncOpenAI | ||
import pytest | ||
|
||
MODEL_THAT_EXISTS = "Systran/faster-whisper-tiny.en" | ||
MODEL_THAT_DOES_NOT_EXIST = "i-do-not-exist" | ||
MIN_EXPECTED_NUMBER_OF_MODELS = 70 # At the time of the test creation there are 89 models | ||
|
||
|
||
def test_list_models(openai_client: OpenAI) -> None: | ||
models = openai_client.models.list().data | ||
@pytest.mark.asyncio() | ||
async def test_list_models(openai_client: AsyncOpenAI) -> None: | ||
models = (await openai_client.models.list()).data | ||
assert len(models) > MIN_EXPECTED_NUMBER_OF_MODELS | ||
|
||
|
||
def test_model_exists(openai_client: OpenAI) -> None: | ||
model = openai_client.models.retrieve(MODEL_THAT_EXISTS) | ||
@pytest.mark.asyncio() | ||
async def test_model_exists(openai_client: AsyncOpenAI) -> None: | ||
model = await openai_client.models.retrieve(MODEL_THAT_EXISTS) | ||
assert model.id == MODEL_THAT_EXISTS | ||
|
||
|
||
def test_model_does_not_exist(openai_client: OpenAI) -> None: | ||
@pytest.mark.asyncio() | ||
async def test_model_does_not_exist(openai_client: AsyncOpenAI) -> None: | ||
with pytest.raises(openai.NotFoundError): | ||
openai_client.models.retrieve(MODEL_THAT_DOES_NOT_EXIST) | ||
await openai_client.models.retrieve(MODEL_THAT_DOES_NOT_EXIST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters