openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
tests/lib/test_assistants.py
50lines · modeblame
a1203812Robert Craigie2 years ago | 1 | from __future__ import annotations |
| 2 | | |
| 3 | import pytest | |
| 4 | | |
| 5 | from openai import OpenAI, AsyncOpenAI | |
1d228856Robert Craigie1 years ago | 6 | from openai._utils import assert_signatures_in_sync |
a1203812Robert Craigie2 years ago | 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: | |
203f094bRobert Craigie2 years ago | 11 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
a1203812Robert Craigie2 years ago | 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 | | |
f14f8593Robert Craigie1 years ago | 19 | |
a1203812Robert Craigie2 years ago | 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: | |
203f094bRobert Craigie2 years ago | 22 | checking_client: OpenAI | AsyncOpenAI = client if sync else async_client |
a1203812Robert Craigie2 years ago | 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 | ) | |
1d228856Robert Craigie1 years ago | 29 | |
| 30 | | |
d50550bdRobert Craigie1 years ago | 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 | | |
1d228856Robert Craigie1 years ago | 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 | ) |