Files
free-claude-code/tests/stream_contract.py
T
Alishahryar1 f3a7528d49 Major refactor: API, providers, messaging, and Anthropic protocol
Consolidates the incremental refactor work into a single change set: modular web tools (api/web_tools), native Anthropic request building and SSE block policy, OpenAI conversion and error handling, provider transports and rate limiting, messaging handler and tree queue, safe logging, smoke tests, and broad test coverage.
2026-04-26 03:01:14 -07:00

19 lines
612 B
Python

"""Shared assertions for canonical provider streaming error envelopes."""
from core.anthropic.stream_contracts import (
assert_anthropic_stream_contract,
parse_sse_text,
text_content,
)
def assert_canonical_stream_error_envelope(
events: list[str], *, user_message_substr: str
) -> None:
"""Native transports emit message_start → text error → message_stop."""
blob = "".join(events)
assert "event: error\ndata:" not in blob
parsed = parse_sse_text(blob)
assert_anthropic_stream_contract(parsed, allow_error=False)
assert user_message_substr in text_content(parsed)