openai/openai-python

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.61.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api_resources/test_files.py

498lines · modeblame

5cfb125aStainless Bot2 years ago1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
08b8179aDavid Schnurr2 years ago2
3from __future__ import annotations
4
5import os
86379b44Stainless Bot2 years ago6from typing import Any, cast
08b8179aDavid Schnurr2 years ago7
aa681899Stainless Bot2 years ago8import httpx
08b8179aDavid Schnurr2 years ago9import pytest
aa681899Stainless Bot2 years ago10from respx import MockRouter
08b8179aDavid Schnurr2 years ago11
86379b44Stainless Bot2 years ago12import openai._legacy_response as _legacy_response
08b8179aDavid Schnurr2 years ago13from openai import OpenAI, AsyncOpenAI
14from tests.utils import assert_matches_type
4a0f0fa0Stainless Bot2 years ago15from openai.types import FileObject, FileDeleted
dfdcf571Stainless Bot1 years ago16from openai.pagination import SyncCursorPage, AsyncCursorPage
08b8179aDavid Schnurr2 years ago17
aa681899Stainless Bot2 years ago18# pyright: reportDeprecated=false
19
08b8179aDavid Schnurr2 years ago20base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
21
22
23class TestFiles:
98d779fbStainless Bot2 years ago24parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
08b8179aDavid Schnurr2 years ago25
26@parametrize
27def test_method_create(self, client: OpenAI) -> None:
28file = client.files.create(
29file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago30purpose="assistants",
08b8179aDavid Schnurr2 years ago31)
32assert_matches_type(FileObject, file, path=["response"])
33
34@parametrize
35def test_raw_response_create(self, client: OpenAI) -> None:
36response = client.files.with_raw_response.create(
37file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago38purpose="assistants",
08b8179aDavid Schnurr2 years ago39)
86379b44Stainless Bot2 years ago40
41assert response.is_closed is True
08b8179aDavid Schnurr2 years ago42assert response.http_request.headers.get("X-Stainless-Lang") == "python"
43file = response.parse()
44assert_matches_type(FileObject, file, path=["response"])
45
86379b44Stainless Bot2 years ago46@parametrize
47def test_streaming_response_create(self, client: OpenAI) -> None:
48with client.files.with_streaming_response.create(
49file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago50purpose="assistants",
86379b44Stainless Bot2 years ago51) as response:
52assert not response.is_closed
53assert response.http_request.headers.get("X-Stainless-Lang") == "python"
54
55file = response.parse()
56assert_matches_type(FileObject, file, path=["response"])
57
58assert cast(Any, response.is_closed) is True
59
08b8179aDavid Schnurr2 years ago60@parametrize
61def test_method_retrieve(self, client: OpenAI) -> None:
62file = client.files.retrieve(
63"string",
64)
65assert_matches_type(FileObject, file, path=["response"])
66
67@parametrize
68def test_raw_response_retrieve(self, client: OpenAI) -> None:
69response = client.files.with_raw_response.retrieve(
70"string",
71)
86379b44Stainless Bot2 years ago72
73assert response.is_closed is True
08b8179aDavid Schnurr2 years ago74assert response.http_request.headers.get("X-Stainless-Lang") == "python"
75file = response.parse()
76assert_matches_type(FileObject, file, path=["response"])
77
86379b44Stainless Bot2 years ago78@parametrize
79def test_streaming_response_retrieve(self, client: OpenAI) -> None:
80with client.files.with_streaming_response.retrieve(
81"string",
82) as response:
83assert not response.is_closed
84assert response.http_request.headers.get("X-Stainless-Lang") == "python"
85
86file = response.parse()
87assert_matches_type(FileObject, file, path=["response"])
88
89assert cast(Any, response.is_closed) is True
90
023a4e66Stainless Bot2 years ago91@parametrize
92def test_path_params_retrieve(self, client: OpenAI) -> None:
93with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
94client.files.with_raw_response.retrieve(
95"",
96)
97
08b8179aDavid Schnurr2 years ago98@parametrize
99def test_method_list(self, client: OpenAI) -> None:
100file = client.files.list()
dfdcf571Stainless Bot1 years ago101assert_matches_type(SyncCursorPage[FileObject], file, path=["response"])
08b8179aDavid Schnurr2 years ago102
baa9f07fRobert Craigie2 years ago103@parametrize
104def test_method_list_with_all_params(self, client: OpenAI) -> None:
105file = client.files.list(
dfdcf571Stainless Bot1 years ago106after="after",
107limit=0,
108order="asc",
109purpose="purpose",
baa9f07fRobert Craigie2 years ago110)
dfdcf571Stainless Bot1 years ago111assert_matches_type(SyncCursorPage[FileObject], file, path=["response"])
baa9f07fRobert Craigie2 years ago112
08b8179aDavid Schnurr2 years ago113@parametrize
114def test_raw_response_list(self, client: OpenAI) -> None:
115response = client.files.with_raw_response.list()
86379b44Stainless Bot2 years ago116
117assert response.is_closed is True
08b8179aDavid Schnurr2 years ago118assert response.http_request.headers.get("X-Stainless-Lang") == "python"
119file = response.parse()
dfdcf571Stainless Bot1 years ago120assert_matches_type(SyncCursorPage[FileObject], file, path=["response"])
08b8179aDavid Schnurr2 years ago121
86379b44Stainless Bot2 years ago122@parametrize
123def test_streaming_response_list(self, client: OpenAI) -> None:
124with client.files.with_streaming_response.list() as response:
125assert not response.is_closed
126assert response.http_request.headers.get("X-Stainless-Lang") == "python"
127
128file = response.parse()
dfdcf571Stainless Bot1 years ago129assert_matches_type(SyncCursorPage[FileObject], file, path=["response"])
86379b44Stainless Bot2 years ago130
131assert cast(Any, response.is_closed) is True
132
08b8179aDavid Schnurr2 years ago133@parametrize
134def test_method_delete(self, client: OpenAI) -> None:
135file = client.files.delete(
136"string",
137)
138assert_matches_type(FileDeleted, file, path=["response"])
139
140@parametrize
141def test_raw_response_delete(self, client: OpenAI) -> None:
142response = client.files.with_raw_response.delete(
143"string",
144)
86379b44Stainless Bot2 years ago145
146assert response.is_closed is True
08b8179aDavid Schnurr2 years ago147assert response.http_request.headers.get("X-Stainless-Lang") == "python"
148file = response.parse()
149assert_matches_type(FileDeleted, file, path=["response"])
150
86379b44Stainless Bot2 years ago151@parametrize
152def test_streaming_response_delete(self, client: OpenAI) -> None:
153with client.files.with_streaming_response.delete(
154"string",
155) as response:
156assert not response.is_closed
157assert response.http_request.headers.get("X-Stainless-Lang") == "python"
158
159file = response.parse()
160assert_matches_type(FileDeleted, file, path=["response"])
161
162assert cast(Any, response.is_closed) is True
163
023a4e66Stainless Bot2 years ago164@parametrize
165def test_path_params_delete(self, client: OpenAI) -> None:
166with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
167client.files.with_raw_response.delete(
168"",
169)
170
08b8179aDavid Schnurr2 years ago171@parametrize
aa681899Stainless Bot2 years ago172@pytest.mark.respx(base_url=base_url)
173def test_method_content(self, client: OpenAI, respx_mock: MockRouter) -> None:
b56cf723Stainless Bot2 years ago174respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
aa681899Stainless Bot2 years ago175file = client.files.content(
08b8179aDavid Schnurr2 years ago176"string",
177)
86379b44Stainless Bot2 years ago178assert isinstance(file, _legacy_response.HttpxBinaryResponseContent)
aa681899Stainless Bot2 years ago179assert file.json() == {"foo": "bar"}
08b8179aDavid Schnurr2 years ago180
181@parametrize
aa681899Stainless Bot2 years ago182@pytest.mark.respx(base_url=base_url)
183def test_raw_response_content(self, client: OpenAI, respx_mock: MockRouter) -> None:
b56cf723Stainless Bot2 years ago184respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
86379b44Stainless Bot2 years ago185
aa681899Stainless Bot2 years ago186response = client.files.with_raw_response.content(
08b8179aDavid Schnurr2 years ago187"string",
188)
86379b44Stainless Bot2 years ago189
190assert response.is_closed is True
08b8179aDavid Schnurr2 years ago191assert response.http_request.headers.get("X-Stainless-Lang") == "python"
192file = response.parse()
86379b44Stainless Bot2 years ago193assert_matches_type(_legacy_response.HttpxBinaryResponseContent, file, path=["response"])
194
195@parametrize
196@pytest.mark.respx(base_url=base_url)
197def test_streaming_response_content(self, client: OpenAI, respx_mock: MockRouter) -> None:
198respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
199with client.files.with_streaming_response.content(
200"string",
201) as response:
202assert not response.is_closed
203assert response.http_request.headers.get("X-Stainless-Lang") == "python"
204
205file = response.parse()
206assert_matches_type(bytes, file, path=["response"])
207
208assert cast(Any, response.is_closed) is True
aa681899Stainless Bot2 years ago209
023a4e66Stainless Bot2 years ago210@parametrize
211@pytest.mark.respx(base_url=base_url)
212def test_path_params_content(self, client: OpenAI) -> None:
213with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
214client.files.with_raw_response.content(
215"",
216)
217
aa681899Stainless Bot2 years ago218@parametrize
219def test_method_retrieve_content(self, client: OpenAI) -> None:
220with pytest.warns(DeprecationWarning):
221file = client.files.retrieve_content(
222"string",
223)
86379b44Stainless Bot2 years ago224
aa681899Stainless Bot2 years ago225assert_matches_type(str, file, path=["response"])
226
227@parametrize
228def test_raw_response_retrieve_content(self, client: OpenAI) -> None:
229with pytest.warns(DeprecationWarning):
230response = client.files.with_raw_response.retrieve_content(
231"string",
232)
86379b44Stainless Bot2 years ago233
234assert response.is_closed is True
aa681899Stainless Bot2 years ago235assert response.http_request.headers.get("X-Stainless-Lang") == "python"
236file = response.parse()
08b8179aDavid Schnurr2 years ago237assert_matches_type(str, file, path=["response"])
238
86379b44Stainless Bot2 years ago239@parametrize
240def test_streaming_response_retrieve_content(self, client: OpenAI) -> None:
241with pytest.warns(DeprecationWarning):
242with client.files.with_streaming_response.retrieve_content(
243"string",
244) as response:
245assert not response.is_closed
246assert response.http_request.headers.get("X-Stainless-Lang") == "python"
247
248file = response.parse()
249assert_matches_type(str, file, path=["response"])
250
251assert cast(Any, response.is_closed) is True
252
023a4e66Stainless Bot2 years ago253@parametrize
254def test_path_params_retrieve_content(self, client: OpenAI) -> None:
255with pytest.warns(DeprecationWarning):
256with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
257client.files.with_raw_response.retrieve_content(
258"",
259)
260
08b8179aDavid Schnurr2 years ago261
262class TestAsyncFiles:
98d779fbStainless Bot2 years ago263parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
08b8179aDavid Schnurr2 years ago264
265@parametrize
98d779fbStainless Bot2 years ago266async def test_method_create(self, async_client: AsyncOpenAI) -> None:
267file = await async_client.files.create(
08b8179aDavid Schnurr2 years ago268file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago269purpose="assistants",
08b8179aDavid Schnurr2 years ago270)
271assert_matches_type(FileObject, file, path=["response"])
272
273@parametrize
98d779fbStainless Bot2 years ago274async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
275response = await async_client.files.with_raw_response.create(
08b8179aDavid Schnurr2 years ago276file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago277purpose="assistants",
08b8179aDavid Schnurr2 years ago278)
86379b44Stainless Bot2 years ago279
280assert response.is_closed is True
08b8179aDavid Schnurr2 years ago281assert response.http_request.headers.get("X-Stainless-Lang") == "python"
282file = response.parse()
283assert_matches_type(FileObject, file, path=["response"])
284
86379b44Stainless Bot2 years ago285@parametrize
98d779fbStainless Bot2 years ago286async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
287async with async_client.files.with_streaming_response.create(
86379b44Stainless Bot2 years ago288file=b"raw file contents",
c4a1dbc2Stainless Bot2 years ago289purpose="assistants",
86379b44Stainless Bot2 years ago290) as response:
291assert not response.is_closed
292assert response.http_request.headers.get("X-Stainless-Lang") == "python"
293
294file = await response.parse()
295assert_matches_type(FileObject, file, path=["response"])
296
297assert cast(Any, response.is_closed) is True
298
08b8179aDavid Schnurr2 years ago299@parametrize
98d779fbStainless Bot2 years ago300async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
301file = await async_client.files.retrieve(
08b8179aDavid Schnurr2 years ago302"string",
303)
304assert_matches_type(FileObject, file, path=["response"])
305
306@parametrize
98d779fbStainless Bot2 years ago307async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
308response = await async_client.files.with_raw_response.retrieve(
08b8179aDavid Schnurr2 years ago309"string",
310)
86379b44Stainless Bot2 years ago311
312assert response.is_closed is True
08b8179aDavid Schnurr2 years ago313assert response.http_request.headers.get("X-Stainless-Lang") == "python"
314file = response.parse()
315assert_matches_type(FileObject, file, path=["response"])
316
86379b44Stainless Bot2 years ago317@parametrize
98d779fbStainless Bot2 years ago318async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
319async with async_client.files.with_streaming_response.retrieve(
86379b44Stainless Bot2 years ago320"string",
321) as response:
322assert not response.is_closed
323assert response.http_request.headers.get("X-Stainless-Lang") == "python"
324
325file = await response.parse()
326assert_matches_type(FileObject, file, path=["response"])
327
328assert cast(Any, response.is_closed) is True
329
023a4e66Stainless Bot2 years ago330@parametrize
98d779fbStainless Bot2 years ago331async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago332with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
98d779fbStainless Bot2 years ago333await async_client.files.with_raw_response.retrieve(
023a4e66Stainless Bot2 years ago334"",
335)
336
08b8179aDavid Schnurr2 years ago337@parametrize
98d779fbStainless Bot2 years ago338async def test_method_list(self, async_client: AsyncOpenAI) -> None:
339file = await async_client.files.list()
dfdcf571Stainless Bot1 years ago340assert_matches_type(AsyncCursorPage[FileObject], file, path=["response"])
08b8179aDavid Schnurr2 years ago341
baa9f07fRobert Craigie2 years ago342@parametrize
98d779fbStainless Bot2 years ago343async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
344file = await async_client.files.list(
dfdcf571Stainless Bot1 years ago345after="after",
346limit=0,
347order="asc",
348purpose="purpose",
baa9f07fRobert Craigie2 years ago349)
dfdcf571Stainless Bot1 years ago350assert_matches_type(AsyncCursorPage[FileObject], file, path=["response"])
baa9f07fRobert Craigie2 years ago351
08b8179aDavid Schnurr2 years ago352@parametrize
98d779fbStainless Bot2 years ago353async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None:
354response = await async_client.files.with_raw_response.list()
86379b44Stainless Bot2 years ago355
356assert response.is_closed is True
08b8179aDavid Schnurr2 years ago357assert response.http_request.headers.get("X-Stainless-Lang") == "python"
358file = response.parse()
dfdcf571Stainless Bot1 years ago359assert_matches_type(AsyncCursorPage[FileObject], file, path=["response"])
08b8179aDavid Schnurr2 years ago360
86379b44Stainless Bot2 years ago361@parametrize
98d779fbStainless Bot2 years ago362async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
363async with async_client.files.with_streaming_response.list() as response:
86379b44Stainless Bot2 years ago364assert not response.is_closed
365assert response.http_request.headers.get("X-Stainless-Lang") == "python"
366
367file = await response.parse()
dfdcf571Stainless Bot1 years ago368assert_matches_type(AsyncCursorPage[FileObject], file, path=["response"])
86379b44Stainless Bot2 years ago369
370assert cast(Any, response.is_closed) is True
371
08b8179aDavid Schnurr2 years ago372@parametrize
98d779fbStainless Bot2 years ago373async def test_method_delete(self, async_client: AsyncOpenAI) -> None:
374file = await async_client.files.delete(
08b8179aDavid Schnurr2 years ago375"string",
376)
377assert_matches_type(FileDeleted, file, path=["response"])
378
379@parametrize
98d779fbStainless Bot2 years ago380async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
381response = await async_client.files.with_raw_response.delete(
08b8179aDavid Schnurr2 years ago382"string",
383)
86379b44Stainless Bot2 years ago384
385assert response.is_closed is True
08b8179aDavid Schnurr2 years ago386assert response.http_request.headers.get("X-Stainless-Lang") == "python"
387file = response.parse()
388assert_matches_type(FileDeleted, file, path=["response"])
389
86379b44Stainless Bot2 years ago390@parametrize
98d779fbStainless Bot2 years ago391async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None:
392async with async_client.files.with_streaming_response.delete(
86379b44Stainless Bot2 years ago393"string",
394) as response:
395assert not response.is_closed
396assert response.http_request.headers.get("X-Stainless-Lang") == "python"
397
398file = await response.parse()
399assert_matches_type(FileDeleted, file, path=["response"])
400
401assert cast(Any, response.is_closed) is True
402
023a4e66Stainless Bot2 years ago403@parametrize
98d779fbStainless Bot2 years ago404async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago405with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
98d779fbStainless Bot2 years ago406await async_client.files.with_raw_response.delete(
023a4e66Stainless Bot2 years ago407"",
408)
409
08b8179aDavid Schnurr2 years ago410@parametrize
aa681899Stainless Bot2 years ago411@pytest.mark.respx(base_url=base_url)
98d779fbStainless Bot2 years ago412async def test_method_content(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
b56cf723Stainless Bot2 years ago413respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
98d779fbStainless Bot2 years ago414file = await async_client.files.content(
08b8179aDavid Schnurr2 years ago415"string",
416)
86379b44Stainless Bot2 years ago417assert isinstance(file, _legacy_response.HttpxBinaryResponseContent)
aa681899Stainless Bot2 years ago418assert file.json() == {"foo": "bar"}
08b8179aDavid Schnurr2 years ago419
420@parametrize
aa681899Stainless Bot2 years ago421@pytest.mark.respx(base_url=base_url)
98d779fbStainless Bot2 years ago422async def test_raw_response_content(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
b56cf723Stainless Bot2 years ago423respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
86379b44Stainless Bot2 years ago424
98d779fbStainless Bot2 years ago425response = await async_client.files.with_raw_response.content(
08b8179aDavid Schnurr2 years ago426"string",
427)
86379b44Stainless Bot2 years ago428
429assert response.is_closed is True
08b8179aDavid Schnurr2 years ago430assert response.http_request.headers.get("X-Stainless-Lang") == "python"
431file = response.parse()
86379b44Stainless Bot2 years ago432assert_matches_type(_legacy_response.HttpxBinaryResponseContent, file, path=["response"])
433
434@parametrize
435@pytest.mark.respx(base_url=base_url)
98d779fbStainless Bot2 years ago436async def test_streaming_response_content(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
86379b44Stainless Bot2 years ago437respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
98d779fbStainless Bot2 years ago438async with async_client.files.with_streaming_response.content(
86379b44Stainless Bot2 years ago439"string",
440) as response:
441assert not response.is_closed
442assert response.http_request.headers.get("X-Stainless-Lang") == "python"
443
444file = await response.parse()
445assert_matches_type(bytes, file, path=["response"])
446
447assert cast(Any, response.is_closed) is True
aa681899Stainless Bot2 years ago448
023a4e66Stainless Bot2 years ago449@parametrize
450@pytest.mark.respx(base_url=base_url)
98d779fbStainless Bot2 years ago451async def test_path_params_content(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago452with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
98d779fbStainless Bot2 years ago453await async_client.files.with_raw_response.content(
023a4e66Stainless Bot2 years ago454"",
455)
456
aa681899Stainless Bot2 years ago457@parametrize
98d779fbStainless Bot2 years ago458async def test_method_retrieve_content(self, async_client: AsyncOpenAI) -> None:
aa681899Stainless Bot2 years ago459with pytest.warns(DeprecationWarning):
98d779fbStainless Bot2 years ago460file = await async_client.files.retrieve_content(
aa681899Stainless Bot2 years ago461"string",
462)
86379b44Stainless Bot2 years ago463
aa681899Stainless Bot2 years ago464assert_matches_type(str, file, path=["response"])
465
466@parametrize
98d779fbStainless Bot2 years ago467async def test_raw_response_retrieve_content(self, async_client: AsyncOpenAI) -> None:
aa681899Stainless Bot2 years ago468with pytest.warns(DeprecationWarning):
98d779fbStainless Bot2 years ago469response = await async_client.files.with_raw_response.retrieve_content(
aa681899Stainless Bot2 years ago470"string",
471)
86379b44Stainless Bot2 years ago472
473assert response.is_closed is True
aa681899Stainless Bot2 years ago474assert response.http_request.headers.get("X-Stainless-Lang") == "python"
475file = response.parse()
08b8179aDavid Schnurr2 years ago476assert_matches_type(str, file, path=["response"])
86379b44Stainless Bot2 years ago477
478@parametrize
98d779fbStainless Bot2 years ago479async def test_streaming_response_retrieve_content(self, async_client: AsyncOpenAI) -> None:
86379b44Stainless Bot2 years ago480with pytest.warns(DeprecationWarning):
98d779fbStainless Bot2 years ago481async with async_client.files.with_streaming_response.retrieve_content(
86379b44Stainless Bot2 years ago482"string",
483) as response:
484assert not response.is_closed
485assert response.http_request.headers.get("X-Stainless-Lang") == "python"
486
487file = await response.parse()
488assert_matches_type(str, file, path=["response"])
489
490assert cast(Any, response.is_closed) is True
023a4e66Stainless Bot2 years ago491
492@parametrize
98d779fbStainless Bot2 years ago493async def test_path_params_retrieve_content(self, async_client: AsyncOpenAI) -> None:
023a4e66Stainless Bot2 years ago494with pytest.warns(DeprecationWarning):
495with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"):
98d779fbStainless Bot2 years ago496await async_client.files.with_raw_response.retrieve_content(
023a4e66Stainless Bot2 years ago497"",
498)