Test scenario: Verify output format consistency across all SSE functions Verify: All start with "data: " and end with "\n\n"
()
| 249 | |
| 250 | |
| 251 | def 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") |
nothing calls this directly
no test coverage detected