Drop STEP_ID constants from data_entry_flow (#59497)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
6a21b241c0
commit
4ecbfe8646
5 changed files with 8 additions and 13 deletions
|
@ -8,7 +8,7 @@ import aiopulse
|
||||||
import async_timeout
|
import async_timeout
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_HOST, CONF_ID
|
from homeassistant.const import CONF_HOST, CONF_ID
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -53,7 +53,7 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
self.discovered_hubs = {hub.id: hub for hub in hubs}
|
self.discovered_hubs = {hub.id: hub for hub in hubs}
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id=data_entry_flow.STEP_ID_USER,
|
step_id="user",
|
||||||
data_schema=vol.Schema(
|
data_schema=vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_ID): vol.In(
|
vol.Required(CONF_ID): vol.In(
|
||||||
|
|
|
@ -16,7 +16,6 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.data_entry_flow import STEP_ID_INIT, STEP_ID_USER
|
|
||||||
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
from homeassistant.helpers import aiohttp_client, config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id=STEP_ID_USER, data_schema=DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -164,7 +163,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
||||||
): vol.All(cv.positive_int, vol.Clamp(min=MIN_SCAN_INTERVAL)),
|
): vol.All(cv.positive_int, vol.Clamp(min=MIN_SCAN_INTERVAL)),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return self.async_show_form(step_id=STEP_ID_INIT, data_schema=data_schema)
|
return self.async_show_form(step_id="init", data_schema=data_schema)
|
||||||
|
|
||||||
|
|
||||||
class CannotConnect(exceptions.HomeAssistantError):
|
class CannotConnect(exceptions.HomeAssistantError):
|
||||||
|
|
|
@ -5,7 +5,7 @@ import abc
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Iterable, Mapping
|
from collections.abc import Iterable, Mapping
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, Final, TypedDict
|
from typing import Any, TypedDict
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -21,9 +21,6 @@ RESULT_TYPE_EXTERNAL_STEP_DONE = "external_done"
|
||||||
RESULT_TYPE_SHOW_PROGRESS = "progress"
|
RESULT_TYPE_SHOW_PROGRESS = "progress"
|
||||||
RESULT_TYPE_SHOW_PROGRESS_DONE = "progress_done"
|
RESULT_TYPE_SHOW_PROGRESS_DONE = "progress_done"
|
||||||
|
|
||||||
STEP_ID_INIT: Final = "init"
|
|
||||||
STEP_ID_USER: Final = "user"
|
|
||||||
|
|
||||||
# Event that is fired when a flow is progressed via external or progress source.
|
# Event that is fired when a flow is progressed via external or progress source.
|
||||||
EVENT_DATA_ENTRY_FLOW_PROGRESSED = "data_entry_flow_progressed"
|
EVENT_DATA_ENTRY_FLOW_PROGRESSED = "data_entry_flow_progressed"
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ async def test_show_form_two_hubs(hass, mock_hub_discover):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == data_entry_flow.STEP_ID_USER
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# Check we performed the discovery
|
# Check we performed the discovery
|
||||||
assert len(mock_hub_discover.mock_calls) == 1
|
assert len(mock_hub_discover.mock_calls) == 1
|
||||||
|
|
|
@ -14,7 +14,6 @@ from homeassistant.const import (
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.data_entry_flow import STEP_ID_INIT
|
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -167,7 +166,7 @@ async def test_option_flow(hass):
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == STEP_ID_INIT
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
@ -187,7 +186,7 @@ async def test_option_flow_defaults(hass):
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
assert result["step_id"] == STEP_ID_INIT
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
|
|
Loading…
Add table
Reference in a new issue