openai/openai-python
Publicmirrored fromhttps://github.com/openai/openai-pythonAvailable
tests/lib/test_assistants.py
50lines · modecode
| 1 | from __future__ import annotations |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | from openai import OpenAI, AsyncOpenAI |
| 6 | from openai._utils import assert_signatures_in_sync |
| 7 | |
| 8 | |
| 9 | @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) |
| 10 | def test_create_and_run_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: |
| 11 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
| 12 | |
| 13 | assert_signatures_in_sync( |
| 14 | checking_client.beta.threads.create_and_run, |
| 15 | checking_client.beta.threads.create_and_run_poll, |
| 16 | exclude_params={"stream"}, |
| 17 | ) |
| 18 | |
| 19 | |
| 20 | @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) |
| 21 | def test_create_and_run_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: |
| 22 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
| 23 | |
| 24 | assert_signatures_in_sync( |
| 25 | checking_client.beta.threads.create_and_run, |
| 26 | checking_client.beta.threads.create_and_run_stream, |
| 27 | exclude_params={"stream"}, |
| 28 | ) |
| 29 | |
| 30 | |
| 31 | @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) |
| 32 | def test_run_stream_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: |
| 33 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
| 34 | |
| 35 | assert_signatures_in_sync( |
| 36 | checking_client.beta.threads.runs.create, |
| 37 | checking_client.beta.threads.runs.stream, |
| 38 | exclude_params={"stream"}, |
| 39 | ) |
| 40 | |
| 41 | |
| 42 | @pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"]) |
| 43 | def test_create_and_poll_method_definition_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None: |
| 44 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
| 45 | |
| 46 | assert_signatures_in_sync( |
| 47 | checking_client.beta.threads.runs.create, |
| 48 | checking_client.beta.threads.runs.create_and_poll, |
| 49 | exclude_params={"stream"}, |
| 50 | ) |
| 51 | |