mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Validate steps in Flowhandler (#102152)
* Validate steps in Flowhandler * Move validation to FlowManager._async_handle_step * Fix _raise_if_not_has_step * Fix config_entries tests * Fix tests * Rename * Add test
This commit is contained in:
@@ -2171,6 +2171,9 @@ async def test_manual_add_overrides_ignored_entry(
|
||||
)
|
||||
return self.async_show_form(step_id="step2")
|
||||
|
||||
async def async_step_step2(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}), patch(
|
||||
"homeassistant.config_entries.ConfigEntries.async_reload"
|
||||
) as async_reload:
|
||||
@@ -2500,6 +2503,9 @@ async def test_partial_flows_hidden(
|
||||
await pause_discovery.wait()
|
||||
return self.async_show_form(step_id="someform")
|
||||
|
||||
async def async_step_someform(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
|
||||
# Start a config entry flow and wait for it to be blocked
|
||||
init_task = asyncio.ensure_future(
|
||||
@@ -2788,6 +2794,9 @@ async def test_flow_with_default_discovery_with_unique_id(
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return self.async_show_form(step_id="mock")
|
||||
|
||||
async def async_step_mock(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
|
||||
result = await manager.flow.async_init(
|
||||
"comp", context={"source": config_entries.SOURCE_DISCOVERY}
|
||||
@@ -2841,6 +2850,9 @@ async def test_default_discovery_in_progress(
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return self.async_show_form(step_id="mock")
|
||||
|
||||
async def async_step_mock(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
|
||||
result = await manager.flow.async_init(
|
||||
"comp",
|
||||
@@ -2878,6 +2890,9 @@ async def test_default_discovery_abort_on_new_unique_flow(
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return self.async_show_form(step_id="mock")
|
||||
|
||||
async def async_step_mock(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
|
||||
# First discovery with default, no unique ID
|
||||
result2 = await manager.flow.async_init(
|
||||
@@ -2922,6 +2937,9 @@ async def test_default_discovery_abort_on_user_flow_complete(
|
||||
await self._async_handle_discovery_without_unique_id()
|
||||
return self.async_show_form(step_id="mock")
|
||||
|
||||
async def async_step_mock(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
with patch.dict(config_entries.HANDLERS, {"comp": TestFlow}):
|
||||
# First discovery with default, no unique ID
|
||||
flow1 = await manager.flow.async_init(
|
||||
@@ -3968,6 +3986,9 @@ async def test_preview_supported(
|
||||
"""Mock Reauth."""
|
||||
return self.async_show_form(step_id="next", preview="test")
|
||||
|
||||
async def async_step_next(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
@staticmethod
|
||||
async def async_setup_preview(hass: HomeAssistant) -> None:
|
||||
"""Set up preview."""
|
||||
@@ -4006,6 +4027,9 @@ async def test_preview_not_supported(
|
||||
"""Mock Reauth."""
|
||||
return self.async_show_form(step_id="user_confirm")
|
||||
|
||||
async def async_step_user_confirm(self, user_input=None):
|
||||
raise NotImplementedError
|
||||
|
||||
mock_integration(hass, MockModule("test"))
|
||||
mock_entity_platform(hass, "config_flow.test", None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user