Simplify jewish_calendar reconfigure flow (#128008)

* Simplify jewish_calendar reconfigure flow

* Adjust
pull/128023/head
epenet 2024-10-09 15:34:11 +02:00 committed by GitHub
parent dd08381167
commit 3d1e57766a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 14 deletions

View File

@ -87,7 +87,6 @@ class JewishCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
"""Handle a config flow for Jewish calendar."""
VERSION = 1
_config_entry: ConfigEntry
@staticmethod
@callback
@ -133,25 +132,17 @@ class JewishCalendarConfigFlow(ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle a reconfiguration flow initialized by the user."""
self._config_entry = self._get_reconfigure_entry()
return await self.async_step_reconfigure_confirm()
async def async_step_reconfigure_confirm(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle a reconfiguration flow initialized by the user."""
reconfigure_entry = self._get_reconfigure_entry()
if not user_input:
return self.async_show_form(
data_schema=self.add_suggested_values_to_schema(
_get_data_schema(self.hass),
{**self._config_entry.data},
reconfigure_entry.data,
),
step_id="reconfigure_confirm",
step_id="reconfigure",
)
return self.async_update_reload_and_abort(
self._config_entry, data=user_input, reason="reconfigure_successful"
)
return self.async_update_reload_and_abort(reconfigure_entry, data=user_input)
class JewishCalendarOptionsFlowHandler(OptionsFlowWithConfigEntry):

View File

@ -177,7 +177,7 @@ async def test_reconfigure(
# init user flow
result = await mock_config_entry.start_reconfigure_flow(hass)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reconfigure_confirm"
assert result["step_id"] == "reconfigure"
# success
result = await hass.config_entries.flow.async_configure(