mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +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
|
@pytest.fixture
|
||||||
def test_wav() -> bytes:
|
def mock_wav() -> bytes:
|
||||||
"""Return one second of empty WAV audio."""
|
"""Return one second of empty WAV audio."""
|
||||||
with io.BytesIO() as wav_io:
|
with io.BytesIO() as wav_io:
|
||||||
with wave.open(wav_io, "wb") as wav_file:
|
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(
|
async def test_send_tts_udp(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||||
test_wav,
|
mock_wav: bytes,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the UDP server calls sendto to transmit audio data to device."""
|
"""Test the UDP server calls sendto to transmit audio data to device."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
"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.started = True
|
||||||
voice_assistant_udp_pipeline_v2.transport = Mock(spec=asyncio.DatagramTransport)
|
voice_assistant_udp_pipeline_v2.transport = Mock(spec=asyncio.DatagramTransport)
|
||||||
@ -593,12 +593,12 @@ async def test_send_tts_api(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_client: APIClient,
|
mock_client: APIClient,
|
||||||
voice_assistant_api_pipeline: VoiceAssistantAPIPipeline,
|
voice_assistant_api_pipeline: VoiceAssistantAPIPipeline,
|
||||||
test_wav,
|
mock_wav: bytes,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the API pipeline calls cli.send_voice_assistant_audio to transmit audio data to device."""
|
"""Test the API pipeline calls cli.send_voice_assistant_audio to transmit audio data to device."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
"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
|
voice_assistant_api_pipeline.started = True
|
||||||
|
|
||||||
@ -686,12 +686,12 @@ async def test_send_tts_wrong_format(
|
|||||||
async def test_send_tts_not_started(
|
async def test_send_tts_not_started(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||||
test_wav,
|
mock_wav: bytes,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the UDP server does not call sendto when not started."""
|
"""Test the UDP server does not call sendto when not started."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
"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.started = False
|
||||||
voice_assistant_udp_pipeline_v2.transport = Mock(spec=asyncio.DatagramTransport)
|
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(
|
async def test_send_tts_transport_none(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
voice_assistant_udp_pipeline_v2: VoiceAssistantUDPPipeline,
|
||||||
test_wav,
|
mock_wav: bytes,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the UDP server does not call sendto when transport is None."""
|
"""Test the UDP server does not call sendto when transport is None."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.esphome.voice_assistant.tts.async_get_media_source_audio",
|
"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.started = True
|
||||||
voice_assistant_udp_pipeline_v2.transport = None
|
voice_assistant_udp_pipeline_v2.transport = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user