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 · modecode

1# 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:
20 strict_client = OpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True)
21 loose_client = OpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=False)
22 parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
23
24 @parametrize
25 def test_method_retrieve(self, client: OpenAI) -> None:
26 step = client.beta.threads.runs.steps.retrieve(
27 "string",
28 thread_id="string",
29 run_id="string",
30 )
31 assert_matches_type(RunStep, step, path=["response"])
32
33 @parametrize
34 def test_raw_response_retrieve(self, client: OpenAI) -> None:
35 response = client.beta.threads.runs.steps.with_raw_response.retrieve(
36 "string",
37 thread_id="string",
38 run_id="string",
39 )
40 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
41 step = response.parse()
42 assert_matches_type(RunStep, step, path=["response"])
43
44 @parametrize
45 def test_method_list(self, client: OpenAI) -> None:
46 step = client.beta.threads.runs.steps.list(
47 "string",
48 thread_id="string",
49 )
50 assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
51
52 @parametrize
53 def test_method_list_with_all_params(self, client: OpenAI) -> None:
54 step = client.beta.threads.runs.steps.list(
55 "string",
56 thread_id="string",
57 after="string",
58 before="string",
59 limit=0,
60 order="asc",
61 )
62 assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
63
64 @parametrize
65 def test_raw_response_list(self, client: OpenAI) -> None:
66 response = client.beta.threads.runs.steps.with_raw_response.list(
67 "string",
68 thread_id="string",
69 )
70 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
71 step = response.parse()
72 assert_matches_type(SyncCursorPage[RunStep], step, path=["response"])
73
74
75class TestAsyncSteps:
76 strict_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=True)
77 loose_client = AsyncOpenAI(base_url=base_url, api_key=api_key, _strict_response_validation=False)
78 parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
79
80 @parametrize
81 async def test_method_retrieve(self, client: AsyncOpenAI) -> None:
82 step = await client.beta.threads.runs.steps.retrieve(
83 "string",
84 thread_id="string",
85 run_id="string",
86 )
87 assert_matches_type(RunStep, step, path=["response"])
88
89 @parametrize
90 async def test_raw_response_retrieve(self, client: AsyncOpenAI) -> None:
91 response = await client.beta.threads.runs.steps.with_raw_response.retrieve(
92 "string",
93 thread_id="string",
94 run_id="string",
95 )
96 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
97 step = response.parse()
98 assert_matches_type(RunStep, step, path=["response"])
99
100 @parametrize
101 async def test_method_list(self, client: AsyncOpenAI) -> None:
102 step = await client.beta.threads.runs.steps.list(
103 "string",
104 thread_id="string",
105 )
106 assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])
107
108 @parametrize
109 async def test_method_list_with_all_params(self, client: AsyncOpenAI) -> None:
110 step = await client.beta.threads.runs.steps.list(
111 "string",
112 thread_id="string",
113 after="string",
114 before="string",
115 limit=0,
116 order="asc",
117 )
118 assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])
119
120 @parametrize
121 async def test_raw_response_list(self, client: AsyncOpenAI) -> None:
122 response = await client.beta.threads.runs.steps.with_raw_response.list(
123 "string",
124 thread_id="string",
125 )
126 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
127 step = response.parse()
128 assert_matches_type(AsyncCursorPage[RunStep], step, path=["response"])
129