MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / test_sse_format_consistency

Function test_sse_format_consistency

tests/api_utils/test_sse.py:251–274  ·  view source on GitHub ↗

Test scenario: Verify output format consistency across all SSE functions Verify: All start with "data: " and end with "\n\n"

()

Source from the content-addressed store, hash-verified

249
250
251def test_sse_format_consistency():
252 """
253 Test scenario: Verify output format consistency across all SSE functions
254 Verify: All start with "data: " and end with "\n\n"
255 """
256 from api_utils.sse import (
257 generate_sse_chunk,
258 generate_sse_error_chunk,
259 generate_sse_stop_chunk,
260 )
261
262 chunk = generate_sse_chunk(delta="test", req_id="req", model="model")
263 stop = generate_sse_stop_chunk(req_id="req", model="model")
264 error = generate_sse_error_chunk(message="error", req_id="req")
265
266 # Verify format consistency
267 assert chunk.startswith("data: ")
268 assert error.startswith("data: ")
269 # stop chunk contains two data: chunks, but also starts with data:
270 assert stop.startswith("data: ")
271
272 assert chunk.endswith("\n\n")
273 assert error.endswith("\n\n")
274 assert stop.endswith("\n\n")

Callers

nothing calls this directly

Calls 3

generate_sse_chunkFunction · 0.90
generate_sse_stop_chunkFunction · 0.90
generate_sse_error_chunkFunction · 0.90

Tested by

no test coverage detected