mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Rename esphome fixture (#118865)
This commit is contained in:
parent
873a842166
commit
4b663dbf01
@ -99,7 +99,7 @@ def voice_assistant_udp_pipeline_v2(
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_wav() -> bytes:
|
||||
def mock_wav() -> bytes:
|
||||
"""Return one second of empty WAV audio."""
|
||||
with io.BytesIO() as wav_io:
|
||||
with wave.open(wav_io, "wb") as wav_file:
|
||||
@ -560,12 +560,12 @@ async def test_send_tts_not_called_when_empty(
|
||||
async def test_send_tts_udp(
|
||||
hass: HomeAssistant,
|
||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||
test_wav,
|
||||
mock_wav: bytes,
|
||||
) -> None:
|
||||
"""Test the UDP server calls sendto to transmit audio data to device."""
|
||||
with patch(
|
||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
||||
return_value=("wav", test_wav),
|
||||
return_value=("wav", mock_wav),
|
||||
):
|
||||
voice_assistant_udp_pipeline_v2.started = True
|
||||
voice_assistant_udp_pipeline_v2.transport = Mock(spec=asyncio.DatagramTransport)
|
||||
@ -593,12 +593,12 @@ async def test_send_tts_api(
|
||||
hass: HomeAssistant,
|
||||
mock_client: APIClient,
|
||||
voice_assistant_api_pipeline: VoiceAssistantAPIPipeline,
|
||||
test_wav,
|
||||
mock_wav: bytes,
|
||||
) -> None:
|
||||
"""Test the API pipeline calls cli.send_voice_assistant_audio to transmit audio data to device."""
|
||||
with patch(
|
||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
||||
return_value=("wav", test_wav),
|
||||
return_value=("wav", mock_wav),
|
||||
):
|
||||
voice_assistant_api_pipeline.started = True
|
||||
|
||||
@ -686,12 +686,12 @@ async def test_send_tts_wrong_format(
|
||||
async def test_send_tts_not_started(
|
||||
hass: HomeAssistant,
|
||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||
test_wav,
|
||||
mock_wav: bytes,
|
||||
) -> None:
|
||||
"""Test the UDP server does not call sendto when not started."""
|
||||
with patch(
|
||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
||||
return_value=("wav", test_wav),
|
||||
return_value=("wav", mock_wav),
|
||||
):
|
||||
voice_assistant_udp_pipeline_v2.started = False
|
||||
voice_assistant_udp_pipeline_v2.transport = Mock(spec=asyncio.DatagramTransport)
|
||||
@ -713,13 +713,13 @@ async def test_send_tts_not_started(
|
||||
async def test_send_tts_transport_none(
|
||||
hass: HomeAssistant,
|
||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||
test_wav,
|
||||
mock_wav: bytes,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test the UDP server does not call sendto when transport is None."""
|
||||
with patch(
|
||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
||||
return_value=("wav", test_wav),
|
||||
return_value=("wav", mock_wav),
|
||||
):
|
||||
voice_assistant_udp_pipeline_v2.started = True
|
||||
voice_assistant_udp_pipeline_v2.transport = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user