fix: await message confirmation interruption
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pipecat.frames.frames import (
|
||||
BotStartedSpeakingFrame,
|
||||
@@ -10,6 +10,7 @@ from pipecat.frames.frames import (
|
||||
OutputTransportMessageUrgentFrame,
|
||||
)
|
||||
from services.pipecat.pipeline_events import bind_cascade_pipeline_events
|
||||
from services.pipecat.pipeline import _interrupt_pipeline_output
|
||||
|
||||
|
||||
class _EventSource:
|
||||
@@ -80,6 +81,25 @@ class _Brain:
|
||||
|
||||
|
||||
class PipelineEventTest(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_output_interruption_broadcasts_before_flush_barrier(self):
|
||||
events = []
|
||||
source = SimpleNamespace(
|
||||
broadcast_interruption=AsyncMock(
|
||||
side_effect=lambda: events.append("broadcast")
|
||||
)
|
||||
)
|
||||
worker = SimpleNamespace(
|
||||
flush_pipeline=AsyncMock(
|
||||
side_effect=lambda **_kwargs: events.append("flush")
|
||||
)
|
||||
)
|
||||
|
||||
await _interrupt_pipeline_output(source, worker)
|
||||
|
||||
self.assertEqual(events, ["broadcast", "flush"])
|
||||
source.broadcast_interruption.assert_awaited_once_with()
|
||||
worker.flush_pipeline.assert_awaited_once_with(timeout=1.0)
|
||||
|
||||
async def test_greeting_keeps_playback_timestamp_until_client_ready(self):
|
||||
transport = _EventSource()
|
||||
text_input = _EventSource()
|
||||
|
||||
Reference in New Issue
Block a user