From 26d3d8a42b9e542becafac20e25c2e86ce605a14 Mon Sep 17 00:00:00 2001 From: "firstof9@gmail.com" Date: Sun, 7 Jul 2024 12:16:17 -0700 Subject: [PATCH] undo single function --- .../mail_and_packages/config_flow.py | 24 +++++++++++-------- tests/test_config_flow.py | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/custom_components/mail_and_packages/config_flow.py b/custom_components/mail_and_packages/config_flow.py index af904b62..d97e2885 100644 --- a/custom_components/mail_and_packages/config_flow.py +++ b/custom_components/mail_and_packages/config_flow.py @@ -463,7 +463,11 @@ async def async_step_reconfig_2(self, user_input=None): return await self.async_step_reconfig_amazon() if self._data[CONF_CUSTOM_IMG]: return await self.async_step_reconfig_3() - await self._complete_reconfig_flow() + + self.hass.config_entries.async_update_entry(self._entry, data=self._data) + await self.hass.config_entries.async_reload(self._entry.entry_id) + _LOGGER.debug("%s reconfigured.", DOMAIN) + return self.async_abort(reason="reconfigure_successful") return await self._show_reconfig_2(user_input) @@ -487,7 +491,10 @@ async def async_step_reconfig_3(self, user_input=None): self._errors, user_input = await _validate_user_input(self._data) self._data.update(user_input) if len(self._errors) == 0: - await self._complete_reconfig_flow() + self.hass.config_entries.async_update_entry(self._entry, data=self._data) + await self.hass.config_entries.async_reload(self._entry.entry_id) + _LOGGER.debug("%s reconfigured.", DOMAIN) + return self.async_abort(reason="reconfigure_successful") return await self._show_reconfig_3(user_input) @@ -515,7 +522,11 @@ async def async_step_reconfig_amazon(self, user_input=None): if len(self._errors) == 0: if self._data[CONF_CUSTOM_IMG]: return await self.async_step_reconfig_3() - await self._complete_reconfig_flow() + + self.hass.config_entries.async_update_entry(self._entry, data=self._data) + await self.hass.config_entries.async_reload(self._entry.entry_id) + _LOGGER.debug("%s reconfigured.", DOMAIN) + return self.async_abort(reason="reconfigure_successful") return await self._show_reconfig_amazon(user_input) @@ -535,10 +546,3 @@ async def _show_reconfig_amazon(self, user_input): data_schema=_get_schema_step_amazon(user_input, defaults), errors=self._errors, ) - - async def _complete_reconfig_flow(self): - """Complete reconfigure flow.""" - self.hass.config_entries.async_update_entry(self._entry, data=self._data) - await self.hass.config_entries.async_reload(self._entry.entry_id) - _LOGGER.debug("%s reconfigured.", DOMAIN) - return self.async_abort(reason="reconfigure_successful") diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index dfce8f61..32bdad87 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1709,5 +1709,6 @@ async def test_reconfigure( assert result["reason"] == "reconfigure_successful" await hass.async_block_till_done() + _LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN))) entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.data.copy() == data