Skip to content

Commit a8e6a6e

Browse files
chore(internal): update jsonl tests
1 parent 7a6c642 commit a8e6a6e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/api_resources/beta/messages/test_batches.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,33 @@ def test_path_params_results(self, client: Anthropic) -> None:
454454
message_batch_id="",
455455
)
456456

457+
@pytest.mark.skip(reason="Mock server doesn't support application/x-jsonl responses")
458+
@parametrize
459+
def test_raw_response_results(self, client: Anthropic) -> None:
460+
response = client.beta.messages.batches.with_raw_response.results(
461+
message_batch_id="message_batch_id",
462+
)
463+
464+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
465+
stream = response.parse()
466+
for item in stream:
467+
assert_matches_type(BetaMessageBatchIndividualResponse, item, path=["line"])
468+
469+
@pytest.mark.skip(reason="Mock server doesn't support application/x-jsonl responses")
470+
@parametrize
471+
def test_streaming_response_results(self, client: Anthropic) -> None:
472+
with client.beta.messages.batches.with_streaming_response.results(
473+
message_batch_id="message_batch_id",
474+
) as response:
475+
assert not response.is_closed
476+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
477+
478+
stream = response.parse()
479+
for item in stream:
480+
assert_matches_type(BetaMessageBatchIndividualResponse, item, path=["item"])
481+
482+
assert cast(Any, response.is_closed) is True
483+
457484

458485
class TestAsyncBatches:
459486
parametrize = pytest.mark.parametrize(
@@ -890,3 +917,15 @@ async def test_path_params_results(self, async_client: AsyncAnthropic) -> None:
890917
await async_client.beta.messages.batches.results(
891918
message_batch_id="",
892919
)
920+
921+
@pytest.mark.skip(reason="Mock server doesn't support application/x-jsonl responses")
922+
@parametrize
923+
async def test_raw_response_results(self, async_client: AsyncAnthropic) -> None:
924+
response = await async_client.beta.messages.batches.with_raw_response.results(
925+
message_batch_id="message_batch_id",
926+
)
927+
928+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
929+
stream = response.parse()
930+
async for item in stream:
931+
assert_matches_type(BetaMessageBatchIndividualResponse, item, path=["line"])

0 commit comments

Comments
 (0)