mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix tts add-on discovery for Wyoming (#92064)
This commit is contained in:
parent
0b9fbb1800
commit
565b26e884
@ -80,7 +80,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
uri = urlparse(self._hassio_discovery.config["uri"])
|
uri = urlparse(self._hassio_discovery.config["uri"])
|
||||||
if service := await WyomingService.create(uri.hostname, uri.port):
|
if service := await WyomingService.create(uri.hostname, uri.port):
|
||||||
if not any(asr for asr in service.info.asr if asr.installed):
|
if not any(
|
||||||
|
asr for asr in service.info.asr if asr.installed
|
||||||
|
) and not any(tts for tts in service.info.tts if tts.installed):
|
||||||
return self.async_abort(reason="no_services")
|
return self.async_abort(reason="no_services")
|
||||||
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
|
@ -37,3 +37,79 @@
|
|||||||
'version': 1,
|
'version': 1,
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_hassio_addon_discovery[info0]
|
||||||
|
FlowResultSnapshot({
|
||||||
|
'context': dict({
|
||||||
|
'source': 'hassio',
|
||||||
|
'unique_id': '1234',
|
||||||
|
}),
|
||||||
|
'data': dict({
|
||||||
|
'host': 'mock-piper',
|
||||||
|
'port': 10200,
|
||||||
|
}),
|
||||||
|
'description': None,
|
||||||
|
'description_placeholders': None,
|
||||||
|
'flow_id': <ANY>,
|
||||||
|
'handler': 'wyoming',
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'result': ConfigEntrySnapshot({
|
||||||
|
'data': dict({
|
||||||
|
'host': 'mock-piper',
|
||||||
|
'port': 10200,
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'wyoming',
|
||||||
|
'entry_id': <ANY>,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'pref_disable_new_entities': False,
|
||||||
|
'pref_disable_polling': False,
|
||||||
|
'source': 'hassio',
|
||||||
|
'title': 'Piper',
|
||||||
|
'unique_id': '1234',
|
||||||
|
'version': 1,
|
||||||
|
}),
|
||||||
|
'title': 'Piper',
|
||||||
|
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
|
||||||
|
'version': 1,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_hassio_addon_discovery[info1]
|
||||||
|
FlowResultSnapshot({
|
||||||
|
'context': dict({
|
||||||
|
'source': 'hassio',
|
||||||
|
'unique_id': '1234',
|
||||||
|
}),
|
||||||
|
'data': dict({
|
||||||
|
'host': 'mock-piper',
|
||||||
|
'port': 10200,
|
||||||
|
}),
|
||||||
|
'description': None,
|
||||||
|
'description_placeholders': None,
|
||||||
|
'flow_id': <ANY>,
|
||||||
|
'handler': 'wyoming',
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'result': ConfigEntrySnapshot({
|
||||||
|
'data': dict({
|
||||||
|
'host': 'mock-piper',
|
||||||
|
'port': 10200,
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'wyoming',
|
||||||
|
'entry_id': <ANY>,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'pref_disable_new_entities': False,
|
||||||
|
'pref_disable_polling': False,
|
||||||
|
'source': 'hassio',
|
||||||
|
'title': 'Piper',
|
||||||
|
'unique_id': '1234',
|
||||||
|
'version': 1,
|
||||||
|
}),
|
||||||
|
'title': 'Piper',
|
||||||
|
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
|
||||||
|
'version': 1,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
from wyoming.info import Info
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.hassio import HassioServiceInfo
|
from homeassistant.components.hassio import HassioServiceInfo
|
||||||
@ -131,10 +132,12 @@ async def test_no_supported_services(hass: HomeAssistant) -> None:
|
|||||||
assert result2["reason"] == "no_services"
|
assert result2["reason"] == "no_services"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("info", [STT_INFO, TTS_INFO])
|
||||||
async def test_hassio_addon_discovery(
|
async def test_hassio_addon_discovery(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
|
info: Info,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config flow initiated by Supervisor."""
|
"""Test config flow initiated by Supervisor."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -149,7 +152,7 @@ async def test_hassio_addon_discovery(
|
|||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.wyoming.data.load_wyoming_info",
|
"homeassistant.components.wyoming.data.load_wyoming_info",
|
||||||
return_value=STT_INFO,
|
return_value=info,
|
||||||
) as mock_wyoming:
|
) as mock_wyoming:
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user