Onboard Google Translate (#95352)
This commit is contained in:
parent
2c9213baa1
commit
4d2fa5bdbc
5 changed files with 49 additions and 5 deletions
|
@ -47,3 +47,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
)
|
||||
|
||||
return self.async_show_form(step_id="user", data_schema=STEP_USER_DATA_SCHEMA)
|
||||
|
||||
async def async_step_onboarding(
|
||||
self, data: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by onboarding."""
|
||||
return self.async_create_entry(
|
||||
title="Google Translate text-to-speech",
|
||||
data={CONF_LANG: DEFAULT_LANG, CONF_TLD: DEFAULT_TLD},
|
||||
)
|
||||
|
|
|
@ -193,7 +193,7 @@ class CoreConfigOnboardingView(_BaseOnboardingView):
|
|||
await self._async_mark_done(hass)
|
||||
|
||||
# Integrations to set up when finishing onboarding
|
||||
onboard_integrations = ["met", "radio_browser"]
|
||||
onboard_integrations = ["google_translate", "met", "radio_browser"]
|
||||
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components import hassio
|
||||
|
|
|
@ -96,10 +96,6 @@ default_config:
|
|||
frontend:
|
||||
themes: !include_dir_merge_named themes
|
||||
|
||||
# Text-to-speech
|
||||
tts:
|
||||
- platform: google_translate
|
||||
|
||||
automation: !include {AUTOMATION_CONFIG_PATH}
|
||||
script: !include {SCRIPT_CONFIG_PATH}
|
||||
scene: !include {SCENE_CONFIG_PATH}
|
||||
|
|
|
@ -66,3 +66,21 @@ async def test_already_configured(
|
|||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
async def test_onboarding_flow(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock
|
||||
) -> None:
|
||||
"""Test the onboarding configuration flow."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "onboarding"}
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "Google Translate text-to-speech"
|
||||
assert result.get("data") == {
|
||||
CONF_LANG: "en",
|
||||
CONF_TLD: "com",
|
||||
}
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
|
|
@ -453,6 +453,27 @@ async def test_onboarding_core_sets_up_met(
|
|||
assert len(hass.config_entries.async_entries("met")) == 1
|
||||
|
||||
|
||||
async def test_onboarding_core_sets_up_google_translate(
|
||||
hass: HomeAssistant,
|
||||
hass_storage: dict[str, Any],
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_default_integrations,
|
||||
) -> None:
|
||||
"""Test finishing the core step sets up google translate."""
|
||||
mock_storage(hass_storage, {"done": [const.STEP_USER]})
|
||||
|
||||
assert await async_setup_component(hass, "onboarding", {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
client = await hass_client()
|
||||
resp = await client.post("/api/onboarding/core_config")
|
||||
|
||||
assert resp.status == 200
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.config_entries.async_entries("google_translate")) == 1
|
||||
|
||||
|
||||
async def test_onboarding_core_sets_up_radio_browser(
|
||||
hass: HomeAssistant,
|
||||
hass_storage: dict[str, Any],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue