From 5bf4fbc24c8d034a28d4dd15d30dc5ea48df26c8 Mon Sep 17 00:00:00 2001 From: Chris <1105672+firstof9@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:20:27 -0700 Subject: [PATCH] refactor: switch to proper reconfig flow (#936) * refactor: switch to proper reconfig flow * update tests, remove commented code * linting --- .../mail_and_packages/__init__.py | 71 +- .../mail_and_packages/config_flow.py | 104 +- .../mail_and_packages/strings.json | 44 +- .../mail_and_packages/translations/ca.json | 42 +- .../mail_and_packages/translations/de.json | 42 +- .../mail_and_packages/translations/en.json | 44 +- .../mail_and_packages/translations/es.json | 42 +- .../translations/es_419.json | 42 +- .../mail_and_packages/translations/fi.json | 42 +- .../mail_and_packages/translations/fr.json | 42 +- .../mail_and_packages/translations/hu.json | 42 +- .../mail_and_packages/translations/it.json | 42 +- .../mail_and_packages/translations/ko.json | 42 +- .../mail_and_packages/translations/nl.json | 42 +- .../mail_and_packages/translations/no.json | 42 +- .../mail_and_packages/translations/pl.json | 42 +- .../mail_and_packages/translations/pt.json | 42 +- .../mail_and_packages/translations/pt_BR.json | 42 +- .../mail_and_packages/translations/ru.json | 42 +- .../mail_and_packages/translations/sk.json | 42 +- .../mail_and_packages/translations/sl.json | 42 +- .../mail_and_packages/translations/sv.json | 42 +- .../translations/zh_Hant_HK.json | 42 +- tests/conftest.py | 2 +- tests/const.py | 5 +- tests/test_binary_sensor.py | 8 +- tests/test_config_flow.py | 1341 ----------------- tests/test_init.py | 2 +- 28 files changed, 903 insertions(+), 1516 deletions(-) diff --git a/custom_components/mail_and_packages/__init__.py b/custom_components/mail_and_packages/__init__.py index 05a05f08..e022d1b1 100644 --- a/custom_components/mail_and_packages/__init__.py +++ b/custom_components/mail_and_packages/__init__.py @@ -11,7 +11,6 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import ( - CONF_ALLOW_EXTERNAL, CONF_AMAZON_DAYS, CONF_AMAZON_FWDS, CONF_IMAGE_SECURITY, @@ -23,13 +22,12 @@ COORDINATOR, DEFAULT_AMAZON_DAYS, DEFAULT_AMAZON_FWDS, - DEFAULT_IMAP_TIMEOUT, DOMAIN, ISSUE_URL, PLATFORMS, VERSION, ) -from .helpers import default_image_path, process_emails +from .helpers import process_emails _LOGGER = logging.getLogger(__name__) @@ -51,36 +49,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b hass.data.setdefault(DOMAIN, {}) updated_config = config_entry.data.copy() - # Set amazon fwd blank if missing - if CONF_AMAZON_FWDS not in updated_config.keys(): - updated_config[CONF_AMAZON_FWDS] = [] - - # Set default timeout if missing - if CONF_IMAP_TIMEOUT not in updated_config.keys(): - updated_config[CONF_IMAP_TIMEOUT] = DEFAULT_IMAP_TIMEOUT - - # Set external path off by default - if CONF_ALLOW_EXTERNAL not in config_entry.data.keys(): - updated_config[CONF_ALLOW_EXTERNAL] = False - - updated_config[CONF_PATH] = default_image_path(hass, config_entry) - - # Set image security always on - if CONF_IMAGE_SECURITY not in config_entry.data.keys(): - updated_config[CONF_IMAGE_SECURITY] = True - # Sort the resources updated_config[CONF_RESOURCES] = sorted(updated_config[CONF_RESOURCES]) if updated_config != config_entry.data: hass.config_entries.async_update_entry(config_entry, data=updated_config) - config_entry.add_update_listener(update_listener) - - hass.config_entries.async_update_entry(config_entry, options=config_entry.data) - config = config_entry.data - # Variables for data coordinator + config = config_entry.data host = config.get(CONF_HOST) the_timeout = config.get(CONF_IMAP_TIMEOUT) interval = config.get(CONF_SCAN_INTERVAL) @@ -124,34 +100,16 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> return unload_ok -async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None: - """Update listener.""" - _LOGGER.debug("Attempting to reload sensors from the %s integration", DOMAIN) - - if config_entry.data == config_entry.options: - _LOGGER.debug("No changes detected not reloading sensors.") - return - - new_data = config_entry.options.copy() - - hass.config_entries.async_update_entry( - entry=config_entry, - data=new_data, - ) - - await hass.config_entries.async_reload(config_entry.entry_id) - - async def async_migrate_entry(hass, config_entry): """Migrate an old config entry.""" version = config_entry.version new_version = 7 + _LOGGER.debug("Migrating from version %s", version) + updated_config = config_entry.data.copy() + # 1 -> 4: Migrate format if version == 1: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - if CONF_AMAZON_FWDS in updated_config.keys(): if not isinstance(updated_config[CONF_AMAZON_FWDS], list): updated_config[CONF_AMAZON_FWDS] = [ @@ -163,7 +121,7 @@ async def async_migrate_entry(hass, config_entry): _LOGGER.warning("Missing configuration data: %s", CONF_AMAZON_FWDS) # Force path change - updated_config[CONF_PATH] = "images/mail_and_packages/" + updated_config[CONF_PATH] = "custom_components/mail_and_packages/images/" # Always on image security if not config_entry.data[CONF_IMAGE_SECURITY]: @@ -174,11 +132,8 @@ async def async_migrate_entry(hass, config_entry): # 2 -> 4 if version <= 2: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - # Force path change - updated_config[CONF_PATH] = "images/mail_and_packages/" + updated_config[CONF_PATH] = "custom_components/mail_and_packages/images/" # Always on image security if not config_entry.data[CONF_IMAGE_SECURITY]: @@ -188,32 +143,20 @@ async def async_migrate_entry(hass, config_entry): updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS if version <= 3: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - # Add default Amazon Days configuration updated_config[CONF_AMAZON_DAYS] = DEFAULT_AMAZON_DAYS if version <= 4: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - if CONF_AMAZON_FWDS in updated_config and updated_config[CONF_AMAZON_FWDS] == [ '""' ]: updated_config[CONF_AMAZON_FWDS] = DEFAULT_AMAZON_FWDS if version <= 5: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - if CONF_VERIFY_SSL not in updated_config: updated_config[CONF_VERIFY_SSL] = True if version <= 6: - _LOGGER.debug("Migrating from version %s", version) - updated_config = config_entry.data.copy() - if CONF_IMAP_SECURITY not in updated_config: updated_config[CONF_IMAP_SECURITY] = "SSL" diff --git a/custom_components/mail_and_packages/config_flow.py b/custom_components/mail_and_packages/config_flow.py index 7c6dda13..4f0f7595 100644 --- a/custom_components/mail_and_packages/config_flow.py +++ b/custom_components/mail_and_packages/config_flow.py @@ -14,7 +14,6 @@ CONF_RESOURCES, CONF_USERNAME, ) -from homeassistant.core import callback from .const import ( CONF_ALLOW_EXTERNAL, @@ -199,7 +198,7 @@ def _get_default(key: str, fallback_default: Any = None) -> None: CONF_RESOURCES, default=_get_default(CONF_RESOURCES) ): cv.multi_select(get_resources()), vol.Optional( - CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS) + CONF_AMAZON_FWDS, default=_get_default(CONF_AMAZON_FWDS, "(none)") ): cv.string, vol.Optional(CONF_AMAZON_DAYS, default=_get_default(CONF_AMAZON_DAYS)): int, vol.Optional( @@ -252,6 +251,7 @@ class MailAndPackagesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): def __init__(self): """Initialize.""" + self._entry = {} self._data = {} self._errors = {} @@ -359,27 +359,15 @@ async def _show_config_3(self, user_input): errors=self._errors, ) - @staticmethod - @callback - def async_get_options_flow(config_entry): - """Redirect to options flow.""" - return MailAndPackagesOptionsFlow(config_entry) - - -class MailAndPackagesOptionsFlow(config_entries.OptionsFlow): - """Options flow for Mail and Packages.""" - - def __init__(self, config_entry): - """Initialize.""" - self.config = config_entry - self._data = dict(config_entry.options) + async def async_step_reconfigure(self, user_input: dict[str, Any] | None = None): + """Add reconfigure step to allow to reconfigure a config entry.""" + self._entry = self.hass.config_entries.async_get_entry(self.context["entry_id"]) + assert self._entry + self._data = dict(self._entry.data) self._errors = {} - async def async_step_init(self, user_input=None): - """Manage Mail and Packages options.""" if user_input is not None: self._data.update(user_input) - valid = await _test_login( user_input[CONF_HOST], user_input[CONF_PORT], @@ -391,21 +379,21 @@ async def async_step_init(self, user_input=None): if not valid: self._errors["base"] = "communication" else: - return await self.async_step_options_2() + return await self.async_step_reconfig_2() - return await self._show_options_form(user_input) + return await self._show_reconfig_form(user_input) - return await self._show_options_form(user_input) + return await self._show_reconfig_form(user_input) - async def _show_options_form(self, user_input): - """Show the configuration form to edit location data.""" + async def _show_reconfig_form(self, user_input): + """Show the configuration form to edit configuration data.""" return self.async_show_form( - step_id="init", + step_id="reconfigure", data_schema=_get_schema_step_1(user_input, self._data), errors=self._errors, ) - async def async_step_options_2(self, user_input=None): + async def async_step_reconfig_2(self, user_input=None): """Configure form step 2.""" self._errors = {} if user_input is not None: @@ -413,58 +401,56 @@ async def async_step_options_2(self, user_input=None): self._data.update(user_input) if len(self._errors) == 0: if self._data[CONF_CUSTOM_IMG]: - return await self.async_step_options_3() - return self.async_create_entry(title="", data=self._data) - return await self._show_step_options_2(user_input) - return await self._show_step_options_2(user_input) + return await self.async_step_reconfig_3() + 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") - async def _show_step_options_2(self, user_input): - """Step 2 of options.""" - # Defaults - defaults = { - CONF_FOLDER: self._data.get(CONF_FOLDER), - CONF_SCAN_INTERVAL: self._data.get(CONF_SCAN_INTERVAL), - CONF_PATH: self._data.get(CONF_PATH), - CONF_DURATION: self._data.get(CONF_DURATION), - CONF_IMAGE_SECURITY: self._data.get(CONF_IMAGE_SECURITY), - CONF_IMAP_TIMEOUT: self._data.get(CONF_IMAP_TIMEOUT) - or DEFAULT_IMAP_TIMEOUT, - CONF_AMAZON_FWDS: self._data.get(CONF_AMAZON_FWDS) or DEFAULT_AMAZON_FWDS, - CONF_AMAZON_DAYS: self._data.get(CONF_AMAZON_DAYS) or DEFAULT_AMAZON_DAYS, - CONF_GENERATE_MP4: self._data.get(CONF_GENERATE_MP4), - CONF_ALLOW_EXTERNAL: self._data.get(CONF_ALLOW_EXTERNAL), - CONF_RESOURCES: self._data.get(CONF_RESOURCES), - CONF_CUSTOM_IMG: self._data.get(CONF_CUSTOM_IMG) or DEFAULT_CUSTOM_IMG, - } + return await self._show_reconfig_2(user_input) + + return await self._show_reconfig_2(user_input) + + async def _show_reconfig_2(self, user_input): + """Step 2 setup.""" + if self._data[CONF_AMAZON_FWDS] == []: + self._data[CONF_AMAZON_FWDS] = "(none)" return self.async_show_form( - step_id="options_2", - data_schema=_get_schema_step_2(self._data, user_input, defaults), + step_id="reconfig_2", + data_schema=_get_schema_step_2(self._data, user_input, self._data), errors=self._errors, ) - async def async_step_options_3(self, user_input=None): - """Configure form step 3.""" + async def async_step_reconfig_3(self, user_input=None): + """Configure form step 2.""" self._errors = {} if user_input is not None: self._data.update(user_input) self._errors, user_input = await _validate_user_input(self._data) if len(self._errors) == 0: - return self.async_create_entry(title="", data=self._data) - return await self._show_step_options_3(user_input) + 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_step_options_3(user_input) + return await self._show_reconfig_3(user_input) - async def _show_step_options_3(self, user_input): + return await self._show_reconfig_3(user_input) + + async def _show_reconfig_3(self, user_input): """Step 3 setup.""" # Defaults defaults = { - CONF_CUSTOM_IMG_FILE: self._data.get(CONF_CUSTOM_IMG_FILE) - or DEFAULT_CUSTOM_IMG_FILE, + CONF_CUSTOM_IMG_FILE: DEFAULT_CUSTOM_IMG_FILE, } return self.async_show_form( - step_id="options_3", + step_id="reconfig_3", data_schema=_get_schema_step_3(user_input, defaults), errors=self._errors, ) diff --git a/custom_components/mail_and_packages/strings.json b/custom_components/mail_and_packages/strings.json index 3b66a237..0f38d355 100644 --- a/custom_components/mail_and_packages/strings.json +++ b/custom_components/mail_and_packages/strings.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Only a single configuration of Mail and Packages is allowed." + "single_instance_allowed": "Only a single configuration of Mail and Packages is allowed.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Unable to connect or login to the mail server. Please check the log for details.", @@ -43,13 +44,50 @@ "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", "title": "Mail and Packages (Step 2 of 2)" }, - "options_3": { + "config_3": { "data": { "custom_img_file": "Path to custom image: (ie: images/my_custom_no_mail.jpg)" }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } } }, "options": { diff --git a/custom_components/mail_and_packages/translations/ca.json b/custom_components/mail_and_packages/translations/ca.json index ebf7630f..7a8ff807 100644 --- a/custom_components/mail_and_packages/translations/ca.json +++ b/custom_components/mail_and_packages/translations/ca.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Només es permet una configuració única de correu i paquets." + "single_instance_allowed": "Només es permet una configuració única de correu i paquets.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "No es pot connectar o iniciar la sessió al servidor de correu. Consulteu el registre per obtenir més detalls.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/de.json b/custom_components/mail_and_packages/translations/de.json index 825657f5..04b01224 100644 --- a/custom_components/mail_and_packages/translations/de.json +++ b/custom_components/mail_and_packages/translations/de.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Es ist nur eine einzige Konfiguration von Mail und Paketen zulässig." + "single_instance_allowed": "Es ist nur eine einzige Konfiguration von Mail und Paketen zulässig.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Es kann keine Verbindung zum Mailserver hergestellt oder angemeldet werden. Bitte überprüfen Sie das Protokoll für Details.", @@ -49,7 +50,44 @@ }, "description": "Geben Sie unten den Pfad und den Dateinamen Ihres benutzerdefinierten keine-Mail-Bildes ein.\n\nBeispiel: images/custom_nomail.gif", "title": "Briefe und Pakete (Schritt 3 von 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/en.json b/custom_components/mail_and_packages/translations/en.json index ab11c2ac..0f063ba6 100644 --- a/custom_components/mail_and_packages/translations/en.json +++ b/custom_components/mail_and_packages/translations/en.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Only a single configuration of Mail and Packages is allowed." + "single_instance_allowed": "Only a single configuration of Mail and Packages is allowed.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Unable to connect or login to the mail server. Please check the log for details.", @@ -43,13 +44,50 @@ "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", "title": "Mail and Packages (Step 2 of 2)" }, - "options_3": { + "config_3": { "data": { "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/es.json b/custom_components/mail_and_packages/translations/es.json index a7723688..4d870ac1 100644 --- a/custom_components/mail_and_packages/translations/es.json +++ b/custom_components/mail_and_packages/translations/es.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Solo se permite una única configuración de correo y paquetes." + "single_instance_allowed": "Solo se permite una única configuración de correo y paquetes.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "No se puede conectar o iniciar sesión en el servidor de correo. Por favor, consulte el registro para más detalles.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/es_419.json b/custom_components/mail_and_packages/translations/es_419.json index bdc79a56..37a62ea7 100644 --- a/custom_components/mail_and_packages/translations/es_419.json +++ b/custom_components/mail_and_packages/translations/es_419.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Solo se permite una única configuración de correo y paquetes." + "single_instance_allowed": "Solo se permite una única configuración de correo y paquetes.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "No se puede conectar o iniciar sesión en el servidor de correo. Por favor, consulte el registro para más detalles.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/fi.json b/custom_components/mail_and_packages/translations/fi.json index 5ab1debe..ad1272ee 100644 --- a/custom_components/mail_and_packages/translations/fi.json +++ b/custom_components/mail_and_packages/translations/fi.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Vain yksi posti- ja pakettien kokoonpano on sallittu." + "single_instance_allowed": "Vain yksi posti- ja pakettien kokoonpano on sallittu.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Ei voida muodostaa yhteyttä tai kirjautua sisään postipalvelimeen. Tarkista lokista yksityiskohdat.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/fr.json b/custom_components/mail_and_packages/translations/fr.json index be8d8ed1..eda2aa61 100644 --- a/custom_components/mail_and_packages/translations/fr.json +++ b/custom_components/mail_and_packages/translations/fr.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Une seule configuration de Mail et Packages est autorisée." + "single_instance_allowed": "Une seule configuration de Mail et Packages est autorisée.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Impossible de se connecter ou de se connecter au serveur de messagerie. Veuillez consulter le journal pour plus de détails.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/hu.json b/custom_components/mail_and_packages/translations/hu.json index b76ee095..41fafeb6 100644 --- a/custom_components/mail_and_packages/translations/hu.json +++ b/custom_components/mail_and_packages/translations/hu.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Csak a Levelek és a Csomagok egyetlen konfigurációja megengedett." + "single_instance_allowed": "Csak a Levelek és a Csomagok egyetlen konfigurációja megengedett.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Nem lehet csatlakozni vagy bejelentkezni az e-mail szerverhez. Kérjük, ellenőrizze a naplót a részletekért.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/it.json b/custom_components/mail_and_packages/translations/it.json index a30d3af8..a227896e 100644 --- a/custom_components/mail_and_packages/translations/it.json +++ b/custom_components/mail_and_packages/translations/it.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "È consentita una sola configurazione di posta e pacchetti." + "single_instance_allowed": "È consentita una sola configurazione di posta e pacchetti.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Impossibile connettersi o accedere al server di posta. Si prega di controllare il registro per i dettagli.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/ko.json b/custom_components/mail_and_packages/translations/ko.json index 4102ad2b..88a6ea9d 100644 --- a/custom_components/mail_and_packages/translations/ko.json +++ b/custom_components/mail_and_packages/translations/ko.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "메일 및 패키지의 단일 구성 만 허용됩니다." + "single_instance_allowed": "메일 및 패키지의 단일 구성 만 허용됩니다.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "메일 서버에 연결하거나 로그인 할 수 없습니다. 자세한 내용은 로그를 확인하십시오.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/nl.json b/custom_components/mail_and_packages/translations/nl.json index 06d553f2..c5b1f230 100644 --- a/custom_components/mail_and_packages/translations/nl.json +++ b/custom_components/mail_and_packages/translations/nl.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Slechts een enkele configuratie van Mail en pakketten is toegestaan." + "single_instance_allowed": "Slechts een enkele configuratie van Mail en pakketten is toegestaan.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Kan geen verbinding maken met of inloggen op de mailserver. Controleer het logboek voor details.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/no.json b/custom_components/mail_and_packages/translations/no.json index 00a1eef3..cfd778c7 100644 --- a/custom_components/mail_and_packages/translations/no.json +++ b/custom_components/mail_and_packages/translations/no.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Bare en enkelt konfigurasjon av e-post og pakker er tillatt." + "single_instance_allowed": "Bare en enkelt konfigurasjon av e-post og pakker er tillatt.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Kan ikke koble til eller logge inn på postserveren. Vennligst sjekk loggen for detaljer.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/pl.json b/custom_components/mail_and_packages/translations/pl.json index 4283cb10..9ca6c326 100644 --- a/custom_components/mail_and_packages/translations/pl.json +++ b/custom_components/mail_and_packages/translations/pl.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Dozwolona jest tylko jedna konfiguracja poczty i pakietów." + "single_instance_allowed": "Dozwolona jest tylko jedna konfiguracja poczty i pakietów.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Nie można połączyć się lub zalogować do serwera pocztowego. Sprawdź szczegóły w dzienniku.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/pt.json b/custom_components/mail_and_packages/translations/pt.json index 3b0b2580..0cef5c55 100644 --- a/custom_components/mail_and_packages/translations/pt.json +++ b/custom_components/mail_and_packages/translations/pt.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Somente uma única configuração de correio e pacotes é permitida." + "single_instance_allowed": "Somente uma única configuração de correio e pacotes é permitida.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Não foi possível conectar ou fazer login no servidor de email. Por favor, verifique o log para obter detalhes.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/pt_BR.json b/custom_components/mail_and_packages/translations/pt_BR.json index 8383294c..467a5c71 100644 --- a/custom_components/mail_and_packages/translations/pt_BR.json +++ b/custom_components/mail_and_packages/translations/pt_BR.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Somente uma única configuração de correio e pacotes é permitida." + "single_instance_allowed": "Somente uma única configuração de correio e pacotes é permitida.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Não foi possível conectar ou fazer login no servidor de email. Por favor, verifique o log para obter detalhes.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/ru.json b/custom_components/mail_and_packages/translations/ru.json index 45bed573..f79d82fb 100644 --- a/custom_components/mail_and_packages/translations/ru.json +++ b/custom_components/mail_and_packages/translations/ru.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Разрешена только одна конфигурация Почты и Пакетов." + "single_instance_allowed": "Разрешена только одна конфигурация Почты и Пакетов.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Невозможно подключиться или войти на почтовый сервер. Пожалуйста, проверьте журнал для деталей.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/sk.json b/custom_components/mail_and_packages/translations/sk.json index 3acc972c..05de28e2 100644 --- a/custom_components/mail_and_packages/translations/sk.json +++ b/custom_components/mail_and_packages/translations/sk.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Je povolená iba jedna konfigurácia pošty a balíkov." + "single_instance_allowed": "Je povolená iba jedna konfigurácia pošty a balíkov.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Nedá sa pripojiť alebo prihlásiť na poštový server. Podrobnosti nájdete v protokole.", @@ -49,7 +50,44 @@ }, "description": "Nižšie zadajte cestu a názov súboru k svojmu vlastnému obrázku bez pošty.\n\nPríklad: images/custom_nomail.gif", "title": "Pošta a balíky (krok 3 z 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Pošta a balíky" }, diff --git a/custom_components/mail_and_packages/translations/sl.json b/custom_components/mail_and_packages/translations/sl.json index d2cc24f3..26b8d895 100644 --- a/custom_components/mail_and_packages/translations/sl.json +++ b/custom_components/mail_and_packages/translations/sl.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Dovoljena je samo ena konfiguracija pošte in paketov." + "single_instance_allowed": "Dovoljena je samo ena konfiguracija pošte in paketov.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Poštnega strežnika ni mogoče povezati ali prijaviti. Za podrobnosti preverite dnevnik.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/sv.json b/custom_components/mail_and_packages/translations/sv.json index 1c05c346..46890391 100644 --- a/custom_components/mail_and_packages/translations/sv.json +++ b/custom_components/mail_and_packages/translations/sv.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "Endast en enda konfiguration av post och paket är tillåten." + "single_instance_allowed": "Endast en enda konfiguration av post och paket är tillåten.", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "Det går inte att ansluta eller logga in på e-postservern. Kontrollera loggen för mer information.", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/custom_components/mail_and_packages/translations/zh_Hant_HK.json b/custom_components/mail_and_packages/translations/zh_Hant_HK.json index e2e2735a..1ebc55fd 100644 --- a/custom_components/mail_and_packages/translations/zh_Hant_HK.json +++ b/custom_components/mail_and_packages/translations/zh_Hant_HK.json @@ -1,7 +1,8 @@ { "config": { "abort": { - "single_instance_allowed": "僅允許郵件和軟件包的單個配置。" + "single_instance_allowed": "僅允許郵件和軟件包的單個配置。", + "reconfigure_successful": "Reconfigure Successful" }, "error": { "communication": "無法連接或登錄到郵件服務器。請檢查日誌以獲取詳細信息。", @@ -49,7 +50,44 @@ }, "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", "title": "Mail and Packages (Step 3 of 3)" - } + }, + "reconfigure": { + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "imap_security": "IMAP Security", + "verify_ssl": "Verify SSL Cert" + }, + "description": "Please enter the connection information of your mail server.", + "title": "Mail and Packages (Step 1 of 2)" + }, + "reconfig_2": { + "data": { + "folder": "Mail Folder", + "scan_interval": "Scanning Interval (minutes)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "generate_mp4": "Create mp4 from images", + "resources": "Sensors List", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "amazon_fwds": "Amazon fowarded email addresses", + "allow_external": "Create image for notification apps", + "amazon_days": "Days back to check for Amazon emails", + "custom_img": "Use custom 'no image' image?" + }, + "description": "Finish the configuration by customizing the following based on your email structure and Home Assistant installation.\n\nFor details on the [Mail and Packages integration](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) options review the [configuration, templates, and automations section](https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/wiki/Configuration-and-Email-Settings#configuration) on GitHub.\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "reconfig_3": { + "data": { + "custom_img_file": "Path to custom image: (i.e.: images/my_custom_no_mail.jpg)" + }, + "description": "Enter the path and file name to your custom no mail image below.\n\nExample: images/custom_nomail.gif", + "title": "Mail and Packages (Step 3 of 3)" + } }, "title": "Mail and Packages" }, diff --git a/tests/conftest.py b/tests/conftest.py index b8783e69..b0e383dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -383,7 +383,7 @@ def mock_imap_mailbox_format3(): ) mock_conn.search.return_value = ("OK", [b"0"]) mock_conn.uid.return_value = ("OK", [b"0"]) - yield mock_conn + yield mock_conn @pytest.fixture() diff --git a/tests/const.py b/tests/const.py index 12e2e04e..4cabfc56 100644 --- a/tests/const.py +++ b/tests/const.py @@ -55,6 +55,7 @@ } FAKE_CONFIG_DATA = { + "allow_external": False, "amazon_days": 3, "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", "custom_img": False, @@ -188,7 +189,7 @@ FAKE_CONFIG_DATA_CORRECTED_EXTERNAL = { "allow_external": True, "amazon_days": 3, - "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", + "amazon_fwds": ["fakeuser@fake.email", "fakeuser2@fake.email"], "custom_img": False, "folder": '"INBOX"', "generate_mp4": False, @@ -251,7 +252,7 @@ FAKE_CONFIG_DATA_CORRECTED = { "allow_external": False, "amazon_days": 3, - "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", + "amazon_fwds": ["fakeuser@fake.email", "fakeuser2@fake.email"], "custom_img": False, "folder": '"INBOX"', "generate_mp4": False, diff --git a/tests/test_binary_sensor.py b/tests/test_binary_sensor.py index cab63aff..bd92c69b 100644 --- a/tests/test_binary_sensor.py +++ b/tests/test_binary_sensor.py @@ -11,7 +11,9 @@ @pytest.mark.asyncio -async def test_binary_sensor_no_updates(hass, mock_imap_no_email, entity_registry: er.EntityRegistry): +async def test_binary_sensor_no_updates( + hass, mock_imap_no_email, entity_registry: er.EntityRegistry +): entry = MockConfigEntry( domain=DOMAIN, title="imap.test.email", @@ -46,9 +48,7 @@ async def test_binary_sensor_no_updates(hass, mock_imap_no_email, entity_registr # reload the integration await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor") - await hass.config_entries.async_forward_entry_setups( - entry, ["binary_sensor"] - ) + await hass.config_entries.async_forward_entry_setups(entry, ["binary_sensor"]) await hass.async_block_till_done() state = hass.states.get("binary_sensor.usps_mail_delivered") diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 0953f89a..fddd7f7d 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1326,1347 +1326,6 @@ async def test_imap_login_error(mock_imap_login_error, caplog): assert "Error logging into IMAP Server:" in caplog.text -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": True, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 15, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "options_3", - { - "custom_img_file": "images/test.gif", - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": True, - "custom_img_file": "images/test.gif", - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "image_name": "mail_today.gif", - "image_path": "custom_components/mail_and_packages/images/", - "image_security": True, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 15, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow( - input_1, - step_id_2, - input_2, - step_id_3, - input_3, - title, - data, - hass, - mock_imap, - mock_update, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - assert await hass.config_entries.async_setup(entry.entry_id) - await hass.async_block_till_done() - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.config_flow.path", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - await hass.async_block_till_done() - - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - await hass.async_block_till_done() - - assert result3["type"] == "form" - assert result3["step_id"] == step_id_3 - result4 = await hass.config_entries.options.async_configure( - result["flow_id"], input_3 - ) - await hass.async_block_till_done() - assert result4["type"] == "create_entry" - assert data == entry.options.copy() - - await hass.async_block_till_done() - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": True, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 15, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "options_3", - { - "custom_img_file": "images/test.gif", - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": True, - "custom_img_file": "images/test.gif", - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "image_name": "mail_today.gif", - "image_path": "custom_components/mail_and_packages/images/", - "image_security": True, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 15, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_invalid_custom_img_path( - input_1, - step_id_2, - input_2, - step_id_3, - input_3, - title, - data, - hass, - mock_imap, - mock_update, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - assert await hass.config_entries.async_setup(entry.entry_id) - await hass.async_block_till_done() - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - await hass.async_block_till_done() - - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - await hass.async_block_till_done() - - assert result3["type"] == "form" - assert result3["step_id"] == step_id_3 - result4 = await hass.config_entries.options.async_configure( - result["flow_id"], input_3 - ) - - assert result4["type"] == "form" - assert result4["step_id"] == step_id_3 - assert result4["errors"] == {"custom_img_file": "file_not_found"} - - -@pytest.mark.parametrize( - "input_1,step_id_2", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "init", - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_connection_error( - input_1, - step_id_2, - hass, - mock_imap, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", - return_value=False, - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - assert result2["errors"] == {"base": "communication"} - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": False, - "folder": '"INBOX"', - "generate_mp4": True, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": False, - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_invalid_ffmpeg( - input_1, - step_id_2, - input_2, - title, - data, - hass, - mock_imap, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=False, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - - assert result3["type"] == "form" - assert result3["errors"] == {CONF_GENERATE_MP4: "ffmpeg_not_found"} - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": False, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": False, - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_index_error( - input_1, - step_id_2, - input_2, - title, - data, - hass, - mock_imap_index_error, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - - assert result3["type"] == "create_entry" - assert entry.options == data - await hass.async_block_till_done() - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": False, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": False, - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_index_error_2( - input_1, - step_id_2, - input_2, - title, - data, - hass, - mock_imap_index_error_2, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - - assert result3["type"] == "create_entry" - assert entry.options == data - await hass.async_block_till_done() - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": False, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": False, - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_mailbox_format2( - input_1, - step_id_2, - input_2, - title, - data, - hass, - mock_imap_mailbox_format2, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - - assert result3["type"] == "create_entry" - assert entry.options == data - await hass.async_block_till_done() - - -@pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", - [ - ( - { - "host": "imap.test.email", - "port": "993", - "username": "test@test.email", - "password": "notarealpassword", - "imap_security": "SSL", - "verify_ssl": False, - }, - "options_2", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": "", - "custom_img": False, - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - }, - "imap.test.email", - { - "allow_external": False, - "amazon_days": 3, - "amazon_fwds": [], - "custom_img": False, - "host": "imap.test.email", - "port": 993, - "username": "test@test.email", - "password": "notarealpassword", - "folder": '"INBOX"', - "generate_mp4": False, - "gif_duration": 5, - "imap_security": "SSL", - "imap_timeout": 30, - "scan_interval": 20, - "resources": [ - "amazon_packages", - "fedex_delivered", - "fedex_delivering", - "fedex_packages", - "mail_updated", - "ups_delivered", - "ups_delivering", - "ups_packages", - "usps_delivered", - "usps_delivering", - "usps_mail", - "usps_packages", - "zpackages_delivered", - "zpackages_transit", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", - "amazon_delivered", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "poczta_polska_delivering", - "poczta_polska_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", - ], - "verify_ssl": False, - }, - ), - ], -) -@pytest.mark.asyncio -async def test_options_flow_mailbox_format3( - input_1, - step_id_2, - input_2, - title, - data, - hass, - mock_imap_mailbox_format3, -): - """Test config flow options.""" - entry = MockConfigEntry( - domain=DOMAIN, - title="imap.test.email", - data=FAKE_CONFIG_DATA, - ) - - entry.add_to_hass(hass) - - await setup.async_setup_component(hass, "persistent_notification", {}) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["errors"] == {} - # assert result["title"] == title_1 - - with patch( - "custom_components.mail_and_packages.config_flow._test_login", return_value=True - ), patch( - "custom_components.mail_and_packages.config_flow._check_ffmpeg", - return_value=True, - ), patch( - "custom_components.mail_and_packages.async_setup", return_value=True - ) as mock_setup, patch( - "custom_components.mail_and_packages.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.options.async_configure( - result["flow_id"], input_1 - ) - assert result2["type"] == "form" - assert result2["step_id"] == step_id_2 - - result3 = await hass.config_entries.options.async_configure( - result["flow_id"], input_2 - ) - - assert result3["type"] == "create_entry" - assert entry.options == data - await hass.async_block_till_done() - - -# @pytest.mark.parametrize( -# "input_1,step_id_2,input_2,title,data", -# [ -# ( -# { -# "host": "imap.test.email", -# "port": "993", -# "username": "test@test.email", -# "password": "notarealpassword", -# "imap_security": "SSL", -# "verify_ssl": False, -# }, -# "options_2", -# { -# "allow_external": False, -# "amazon_fwds": "(none)", -# "custom_img": False, -# "folder": '"INBOX"', -# "generate_mp4": False, -# "gif_duration": 5, -# "imap_timeout": 30, -# "image_security": True, -# "scan_interval": 15, -# "resources": [ -# "amazon_packages", -# "fedex_delivered", -# "fedex_delivering", -# "fedex_packages", -# "mail_updated", -# "ups_delivered", -# "ups_delivering", -# "ups_packages", -# "usps_delivered", -# "usps_delivering", -# "usps_mail", -# "usps_packages", -# "zpackages_delivered", -# "zpackages_transit", -# "dhl_delivered", -# "dhl_delivering", -# "dhl_packages", -# "amazon_delivered", -# "auspost_delivered", -# "auspost_delivering", -# "auspost_packages", -# "poczta_polska_delivering", -# "poczta_polska_packages", -# "inpost_pl_delivered", -# "inpost_pl_delivering", -# "inpost_pl_packages", -# ], -# }, -# "imap.test.email", -# { -# "allow_external": False, -# "amazon_days": 3, -# "amazon_fwds": [], -# "custom_img": False, -# "host": "imap.test.email", -# "port": 993, -# "username": "test@test.email", -# "password": "notarealpassword", -# "folder": '"INBOX"', -# "generate_mp4": False, -# "gif_duration": 5, -# "image_name": "mail_today.gif", -# "image_path": "custom_components/mail_and_packages/images/", -# "image_security": True, -# "imap_security": "SSL", -# "imap_timeout": 30, -# "scan_interval": 15, -# "resources": [ -# "amazon_packages", -# "fedex_delivered", -# "fedex_delivering", -# "fedex_packages", -# "mail_updated", -# "ups_delivered", -# "ups_delivering", -# "ups_packages", -# "usps_delivered", -# "usps_delivering", -# "usps_mail", -# "usps_packages", -# "zpackages_delivered", -# "zpackages_transit", -# "dhl_delivered", -# "dhl_delivering", -# "dhl_packages", -# "amazon_delivered", -# "auspost_delivered", -# "auspost_delivering", -# "auspost_packages", -# "poczta_polska_delivering", -# "poczta_polska_packages", -# "inpost_pl_delivered", -# "inpost_pl_delivering", -# "inpost_pl_packages", -# ], -# "verify_ssl": False, -# }, -# ), -# ], -# ) -# @pytest.mark.asyncio -# async def test_options_flow_bad( -# input_1, -# step_id_2, -# input_2, -# title, -# data, -# hass, -# mock_imap, -# mock_update, -# ): -# """Test config flow options.""" -# entry = MockConfigEntry( -# domain=DOMAIN, -# title="imap.test.email", -# data=FAKE_CONFIG_DATA_BAD, -# ) - -# entry.add_to_hass(hass) - -# assert await hass.config_entries.async_setup(entry.entry_id) -# await hass.async_block_till_done() - -# await setup.async_setup_component(hass, "persistent_notification", {}) -# result = await hass.config_entries.options.async_init(entry.entry_id) - -# assert result["type"] == "form" -# assert result["errors"] == {} -# # assert result["title"] == title_1 - -# with patch( -# "custom_components.mail_and_packages.config_flow._test_login", return_value=True -# ), patch( -# "custom_components.mail_and_packages.config_flow._check_ffmpeg", -# return_value=True, -# ), patch( -# "custom_components.mail_and_packages.async_setup", return_value=True -# ) as mock_setup, patch( -# "custom_components.mail_and_packages.async_setup_entry", -# return_value=True, -# ) as mock_setup_entry: -# result2 = await hass.config_entries.options.async_configure( -# result["flow_id"], input_1 -# ) -# await hass.async_block_till_done() - -# assert result2["type"] == "form" -# assert result2["step_id"] == step_id_2 - -# result3 = await hass.config_entries.options.async_configure( -# result["flow_id"], input_2 -# ) -# await hass.async_block_till_done() - -# assert result3["type"] == "create_entry" -# assert data == entry.options.copy() - - @pytest.mark.parametrize( "input_1,step_id_2,input_2", [ diff --git a/tests/test_init.py b/tests/test_init.py index 5c7a9631..44dfc7ad 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -74,7 +74,7 @@ async def test_no_path_no_sec( """Test settting up entities.""" entry = integration_no_path - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 41 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1