refactor: extrai coordenação da conversa para VoiceSession
This commit is contained in:
@@ -28,7 +28,18 @@ from voice_assistant.tts.mock import MockTTSAdapter
|
||||
from voice_assistant.voice_pipeline import VoicePipeline
|
||||
|
||||
|
||||
from voice_assistant.audio_gateway.app.main import forward_stt_events
|
||||
from voice_assistant.application import voice_session as voice_session_module
|
||||
from voice_assistant.application.voice_session import VoiceSession
|
||||
|
||||
|
||||
async def forward_stt_events(websocket, stt, pipeline, session_id, turn_id):
|
||||
# Exercise application event handling with the real WebSocket mapper.
|
||||
async def emit(event):
|
||||
await main.send_voice_event(websocket, event)
|
||||
|
||||
conversation = VoiceSession(pipeline=pipeline, create_stt=lambda: stt, emit=emit)
|
||||
await conversation._consume_stt_events(stt, turn_id)
|
||||
|
||||
from voice_assistant.stt.models import TranscriptEvent
|
||||
|
||||
created_stt: list[MockSTTAdapter] = []
|
||||
@@ -853,7 +864,7 @@ def test_websocket_disconnect_continues_cleanup_after_stt_abort_failure(
|
||||
side_effect=failing_abort,
|
||||
):
|
||||
with patch.object(
|
||||
main.logger,
|
||||
voice_session_module.logger,
|
||||
"exception",
|
||||
) as log_mock:
|
||||
with client.websocket_connect("/ws/audio") as websocket:
|
||||
@@ -932,7 +943,7 @@ def test_websocket_disconnect_continues_cleanup_after_task_cancel_failure():
|
||||
side_effect=tracked_abort,
|
||||
),
|
||||
patch.object(
|
||||
main.logger,
|
||||
voice_session_module.logger,
|
||||
"exception",
|
||||
) as log_mock,
|
||||
):
|
||||
@@ -1591,7 +1602,7 @@ def test_websocket_audio_start_abort_failure_is_not_retryable():
|
||||
return_value=failing_stt,
|
||||
),
|
||||
patch.object(
|
||||
main.logger,
|
||||
voice_session_module.logger,
|
||||
"exception",
|
||||
) as log_mock,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user