Skip to content

Commit 706ad78

Browse files
committed
replace open streaming snapshot with lbl assertions
1 parent 7ead79d commit 706ad78

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tests/models/test_openai.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -632,22 +632,24 @@ async def test_stream_with_embedded_thinking_sets_metadata(allow_model_requests:
632632
assert [c async for c in result.stream_text(debounce_by=None)] == snapshot(['response'])
633633

634634
# Verify ThinkingPart has id='content' and provider_name='openai' (covers lines 1748-1749)
635-
assert result.all_messages() == snapshot(
636-
[
637-
ModelRequest(parts=[UserPromptPart(content='', timestamp=IsNow(tz=timezone.utc))]),
638-
ModelResponse(
639-
parts=[
640-
ThinkingPart(content='reasoning', id='content', provider_name='openai'),
641-
TextPart(content='response'),
642-
],
643-
usage=RequestUsage(input_tokens=10, output_tokens=5),
644-
model_name='gpt-4o-123',
645-
timestamp=datetime(2024, 1, 1, 0, 0, tzinfo=timezone.utc),
646-
provider_name='openai',
647-
provider_response_id='123',
648-
),
649-
]
650-
)
635+
messages = result.all_messages()
636+
assert len(messages) == 2
637+
assert isinstance(messages[0], ModelRequest)
638+
assert isinstance(messages[1], ModelResponse)
639+
640+
response = messages[1]
641+
assert len(response.parts) == 2
642+
643+
# This is what we're testing - the ThinkingPart should have these metadata fields set
644+
thinking_part = response.parts[0]
645+
assert isinstance(thinking_part, ThinkingPart)
646+
assert thinking_part.id == 'content' # Line 1748 in openai.py
647+
assert thinking_part.provider_name == 'openai' # Line 1749 in openai.py
648+
assert thinking_part.content == 'reasoning'
649+
650+
text_part = response.parts[1]
651+
assert isinstance(text_part, TextPart)
652+
assert text_part.content == 'response'
651653

652654

653655
async def test_no_delta(allow_model_requests: None):

0 commit comments

Comments
 (0)