6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Pin the exact SSE wire bytes the FE parser depends on."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from app.services.streaming.envelope import (
|
|
format_done,
|
|
format_sse,
|
|
get_response_headers,
|
|
)
|
|
|
|
pytestmark = pytest.mark.unit
|
|
|
|
|
|
class TestFormatSse:
|
|
def test_dict_payload_is_json_serialised(self) -> None:
|
|
frame = format_sse({"type": "start", "messageId": "msg_1"})
|
|
assert frame.startswith("data: ")
|
|
assert frame.endswith("\n\n")
|
|
body = frame[len("data: ") : -2]
|
|
assert json.loads(body) == {"type": "start", "messageId": "msg_1"}
|
|
|
|
def test_string_payload_is_emitted_verbatim(self) -> None:
|
|
frame = format_sse('{"already":"json"}')
|
|
assert frame == 'data: {"already":"json"}\n\n'
|
|
|
|
def test_nested_payload_round_trips(self) -> None:
|
|
payload = {
|
|
"type": "data-action-log",
|
|
"data": {"id": 7, "tool_name": "ls", "reversible": False},
|
|
}
|
|
frame = format_sse(payload)
|
|
body = frame.removeprefix("data: ").removesuffix("\n\n")
|
|
assert json.loads(body) == payload
|
|
|
|
|
|
class TestFormatDone:
|
|
def test_done_marker_is_literal(self) -> None:
|
|
assert format_done() == "data: [DONE]\n\n"
|
|
|
|
|
|
class TestResponseHeaders:
|
|
def test_headers_pin_ai_sdk_v1_protocol(self) -> None:
|
|
headers = get_response_headers()
|
|
assert headers["Content-Type"] == "text/event-stream"
|
|
assert headers["Cache-Control"] == "no-cache"
|
|
assert headers["Connection"] == "keep-alive"
|
|
assert headers["x-vercel-ai-ui-message-stream"] == "v1"
|