Files
romm/backend/tests/streaming_stubs.py
Georges-Antoine Assi aa80073d34 feat(streaming): run exit save pulls on the streaming worker
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 11:34:05 -04:00

21 lines
682 B
Python

"""Streaming queue stub shared by the streaming endpoint and reaper tests."""
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Any
from unittest.mock import MagicMock, patch
from handler.streaming import background
@contextmanager
def exit_pulls_spawned_inline() -> Iterator[MagicMock]:
"""Run each queued exit save pull as a spawned task, as no worker runs here."""
def enqueue(func: Any, *, kwargs: dict[str, Any], **_: Any) -> None:
background.spawn_sync_task(func(**kwargs))
with patch("handler.streaming.lifecycle.streaming_queue") as queue:
queue.enqueue.side_effect = enqueue
yield queue