Config flow to allow marking itself as confirm only (#47607)
This commit is contained in:
parent
573c40cb11
commit
67effbc8c4
3 changed files with 17 additions and 0 deletions
|
@ -1012,6 +1012,13 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _set_confirm_only(
|
||||||
|
self,
|
||||||
|
) -> None:
|
||||||
|
"""Mark the config flow as only needing user confirmation to finish flow."""
|
||||||
|
self.context["confirm_only"] = True
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_current_entries(self, include_ignore: bool = False) -> List[ConfigEntry]:
|
def _async_current_entries(self, include_ignore: bool = False) -> List[ConfigEntry]:
|
||||||
"""Return current entries.
|
"""Return current entries.
|
||||||
|
|
|
@ -42,6 +42,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Confirm setup."""
|
"""Confirm setup."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
|
self._set_confirm_only()
|
||||||
return self.async_show_form(step_id="confirm")
|
return self.async_show_form(step_id="confirm")
|
||||||
|
|
||||||
if self.source == config_entries.SOURCE_USER:
|
if self.source == config_entries.SOURCE_USER:
|
||||||
|
|
|
@ -78,6 +78,15 @@ async def test_user_has_confirmation(hass, discovery_flow_conf):
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
|
progress = hass.config_entries.flow.async_progress()
|
||||||
|
assert len(progress) == 1
|
||||||
|
assert progress[0]["flow_id"] == result["flow_id"]
|
||||||
|
assert progress[0]["context"] == {
|
||||||
|
"confirm_only": True,
|
||||||
|
"source": config_entries.SOURCE_USER,
|
||||||
|
"unique_id": "test",
|
||||||
|
}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue