Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(internal): fix binary response tests #983

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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