openai/openai-python

Public

mirrored from https://github.com/openai/openai-pythonAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.3.7

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api_resources/beta/threads/runs/test_steps.py

128lines · modeblame

baa9f07fRobert Craigie2 years ago1# File generated from our OpenAPI spec by Stainless.
2
3from __future__ import annotations
4
5import os
6
7import pytest
8
9from openai import OpenAI, AsyncOpenAI
10from tests.utils import assert_matches_type
11from openai._client import OpenAI, AsyncOpenAI
12from openai.pagination import SyncCursorPage, AsyncCursorPage
13from openai.types.beta.threads.runs import RunStep
14
15base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
16api_key = "My API Key"
17
18
19class TestSteps:
20strict_client = OpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True)
21loose_client = OpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=False)
22parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
23
24@parametrize
25def test_method_retrieve(self, client: OpenAI) -> None:
26step = client.beta.threads.runs.steps.retrieve(
27"string",
28thread_id="string",
29run_id="string",
30)
31assert_matches_type(RunStep, step, path=["response"])
32
33@parametrize
34def test_raw_response_retrieve(self, client: OpenAI) -> None:
35response = client.beta.threads.runs.steps.with_raw_response.retrieve(
36"string",
37thread_id="string",
38run_id="string",
39)
40assert response.http_request.headers.get("X-Stainless-Lang") == "python"
41step = response.parse()
42assert_matches_type(RunStep, step, path=["response"])
43
44@parametrize
45def test_method_list(self, client: OpenAI) -> None:
46step = client.beta.threads.runs.steps.list(
47"string",
48thread_id="string",
49)
50assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
51
52@parametrize
53def test_method_list_with_all_params(self, client: OpenAI) -> None:
54step = client.beta.threads.runs.steps.list(
55"string",
56thread_id="string",
57after="string",
58before="string",
59limit=0,
60order="asc",
61)
62assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
63
64@parametrize
65def test_raw_response_list(self, client: OpenAI) -> None:
66response = client.beta.threads.runs.steps.with_raw_response.list(
67"string",
68thread_id="string",
69)
70assert response.http_request.headers.get("X-Stainless-Lang") == "python"
71step = response.parse()
72assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
73
74
75class TestAsyncSteps:
76strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True)
77loose_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=False)
78parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
79
80@parametrize
81async def test_method_retrieve(self, client: AsyncOpenAI) -> None:
82step = await client.beta.threads.runs.steps.retrieve(
83"string",
84thread_id="string",
85run_id="string",
86)
87assert_matches_type(RunStep, step, path=["response"])
88
89@parametrize
90async def test_raw_response_retrieve(self, client: AsyncOpenAI) -> None:
91response = await client.beta.threads.runs.steps.with_raw_response.retrieve(
92"string",
93thread_id="string",
94run_id="string",
95)
96assert response.http_request.headers.get("X-Stainless-Lang") == "python"
97step = response.parse()
98assert_matches_type(RunStep, step, path=["response"])
99
100@parametrize
101async def test_method_list(self, client: AsyncOpenAI) -> None:
102step = await client.beta.threads.runs.steps.list(
103"string",
104thread_id="string",
105)
106assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])
107
108@parametrize
109async def test_method_list_with_all_params(self, client: AsyncOpenAI) -> None:
110step = await client.beta.threads.runs.steps.list(
111"string",
112thread_id="string",
113after="string",
114before="string",
115limit=0,
116order="asc",
117)
118assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])
119
120@parametrize
121async def test_raw_response_list(self, client: AsyncOpenAI) -> None:
122response = await client.beta.threads.runs.steps.with_raw_response.list(
123"string",
124thread_id="string",
125)
126assert response.http_request.headers.get("X-Stainless-Lang") == "python"
127step = response.parse()
128assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])