Skip to content

Commit

Permalink
chore(internal): fix binary response tests (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Dec 18, 2023
1 parent 15d3aba commit 89b9cd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions tests/api_resources/audio/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def test_method_create(self, client: OpenAI, respx_mock: MockRouter) -> None:
@pytest.mark.respx(base_url=base_url)
def test_method_create_with_all_params(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
client.audio.speech.create(
speech = client.audio.speech.create(
input="string",
model="string",
voice="alloy",
Expand Down Expand Up @@ -89,8 +88,7 @@ async def test_method_create(self, client: AsyncOpenAI, respx_mock: MockRouter)
@pytest.mark.respx(base_url=base_url)
async def test_method_create_with_all_params(self, client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
await client.audio.speech.create(
speech = await client.audio.speech.create(
input="string",
model="string",
voice="alloy",
Expand Down
12 changes: 4 additions & 8 deletions tests/api_resources/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,20 @@ def test_raw_response_delete(self, client: OpenAI) -> None:
file = response.parse()
assert_matches_type(FileDeleted, file, path=["response"])

@pytest.mark.skip(reason="mocked response isn't working yet")
@parametrize
@pytest.mark.respx(base_url=base_url)
def test_method_content(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.get("/files/{file_id}/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
file = client.files.content(
"string",
)
assert isinstance(file, BinaryResponseContent)
assert file.json() == {"foo": "bar"}

@pytest.mark.skip(reason="mocked response isn't working yet")
@parametrize
@pytest.mark.respx(base_url=base_url)
def test_raw_response_content(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.get("/files/{file_id}/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = client.files.with_raw_response.content(
"string",
)
Expand Down Expand Up @@ -212,22 +210,20 @@ async def test_raw_response_delete(self, client: AsyncOpenAI) -> None:
file = response.parse()
assert_matches_type(FileDeleted, file, path=["response"])

@pytest.mark.skip(reason="mocked response isn't working yet")
@parametrize
@pytest.mark.respx(base_url=base_url)
async def test_method_content(self, client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.get("/files/{file_id}/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
file = await client.files.content(
"string",
)
assert isinstance(file, BinaryResponseContent)
assert file.json() == {"foo": "bar"}

@pytest.mark.skip(reason="mocked response isn't working yet")
@parametrize
@pytest.mark.respx(base_url=base_url)
async def test_raw_response_content(self, client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.get("/files/{file_id}/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
respx_mock.get("/files/string/content").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
response = await client.files.with_raw_response.content(
"string",
)
Expand Down

0 comments on commit 89b9cd9

Please sign in to comment.