From 2f57315e7ef13a2a786549516a6ab16d89e413f1 Mon Sep 17 00:00:00 2001 From: Chris <1105672+firstof9@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:50:02 -0700 Subject: [PATCH] feat: allow image storage location to be configured (#976) * feat: allow image storage location to be configured * update tests * formatting Signed-off-by: firstof9@gmail.com * linting * fix tests again * formatting * fix tests, add error and translations for invalid path * formatting * update tests * more test updates --------- Signed-off-by: firstof9@gmail.com --- .../mail_and_packages/binary_sensor.py | 6 +- .../mail_and_packages/config_flow.py | 107 ++- custom_components/mail_and_packages/const.py | 2 + .../mail_and_packages/helpers.py | 7 +- .../mail_and_packages/strings.json | 223 ++--- .../mail_and_packages/translations/ca.json | 17 +- .../mail_and_packages/translations/de.json | 17 +- .../mail_and_packages/translations/en.json | 17 +- .../mail_and_packages/translations/es.json | 17 +- .../translations/es_419.json | 17 +- .../mail_and_packages/translations/fi.json | 17 +- .../mail_and_packages/translations/fr.json | 17 +- .../mail_and_packages/translations/hu.json | 17 +- .../mail_and_packages/translations/it.json | 17 +- .../mail_and_packages/translations/ko.json | 17 +- .../mail_and_packages/translations/nl.json | 17 +- .../mail_and_packages/translations/no.json | 17 +- .../mail_and_packages/translations/pl.json | 17 +- .../mail_and_packages/translations/pt.json | 17 +- .../mail_and_packages/translations/pt_BR.json | 17 +- .../mail_and_packages/translations/ru.json | 17 +- .../mail_and_packages/translations/sk.json | 17 +- .../mail_and_packages/translations/sl.json | 17 +- .../mail_and_packages/translations/sv.json | 17 +- .../translations/zh_Hant_HK.json | 17 +- tests/const.py | 2 + tests/test_config_flow.py | 862 ++++++++++++++++-- tests/test_helpers.py | 1 + 28 files changed, 1320 insertions(+), 230 deletions(-) diff --git a/custom_components/mail_and_packages/binary_sensor.py b/custom_components/mail_and_packages/binary_sensor.py index efdb63b2..2919c098 100644 --- a/custom_components/mail_and_packages/binary_sensor.py +++ b/custom_components/mail_and_packages/binary_sensor.py @@ -85,7 +85,8 @@ def available(self) -> bool: def is_on(self) -> bool: """Return True if the image is updated.""" if self._type == "usps_update": - if ATTR_IMAGE_NAME in self.coordinator.data.keys(): + attributes = (ATTR_IMAGE_NAME, ATTR_IMAGE_PATH) + if set(attributes).issubset(self.coordinator.data.keys()): image = self.coordinator.data[ATTR_IMAGE_NAME] path = self.coordinator.data[ATTR_IMAGE_PATH] usps_image = f"{self.hass.config.path()}/{path}{image}" @@ -104,7 +105,8 @@ def is_on(self) -> bool: return False if self._type == "amazon_update": - if ATTR_AMAZON_IMAGE in self.coordinator.data.keys(): + attributes = (ATTR_AMAZON_IMAGE, ATTR_IMAGE_PATH) + if set(attributes).issubset(self.coordinator.data.keys()): image = self.coordinator.data[ATTR_AMAZON_IMAGE] path = f"{self.coordinator.data[ATTR_IMAGE_PATH]}amazon/" amazon_image = f"{self.hass.config.path()}/{path}{image}" diff --git a/custom_components/mail_and_packages/config_flow.py b/custom_components/mail_and_packages/config_flow.py index 5f9ede48..15c1b065 100644 --- a/custom_components/mail_and_packages/config_flow.py +++ b/custom_components/mail_and_packages/config_flow.py @@ -22,6 +22,7 @@ CONF_AMAZON_FWDS, CONF_CUSTOM_IMG, CONF_CUSTOM_IMG_FILE, + CONF_STORAGE, CONF_DURATION, CONF_FOLDER, CONF_GENERATE_MP4, @@ -45,6 +46,7 @@ DEFAULT_PATH, DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, + DEFAULT_STORAGE, DOMAIN, ) from .helpers import _check_ffmpeg, _test_login, get_resources, login @@ -129,6 +131,14 @@ async def _validate_user_input(user_input: dict) -> tuple: if not valid: errors[CONF_CUSTOM_IMG_FILE] = "file_not_found" + # validate path exists + if CONF_STORAGE in user_input: + valid = path.exists(user_input[CONF_STORAGE]) + else: + valid = True + if not valid: + errors[CONF_STORAGE] = "path_not_found" + return errors, user_input @@ -274,6 +284,22 @@ def _get_default(key: str, fallback_default: Any = None) -> None: ) +def _get_schema_step_storage(user_input: list, default_dict: list) -> Any: + """Get a schema using the default_dict as a backup.""" + if user_input is None: + user_input = {} + + def _get_default(key: str, fallback_default: Any = None) -> None: + """Get default value for key.""" + return user_input.get(key, default_dict.get(key, fallback_default)) + + return vol.Schema( + { + vol.Required(CONF_STORAGE, default=_get_default(CONF_STORAGE)): cv.string, + } + ) + + @config_entries.HANDLERS.register(DOMAIN) class MailAndPackagesFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Config flow for Mail and Packages.""" @@ -374,9 +400,7 @@ async def async_step_config_3(self, user_input=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=self._data[CONF_HOST], data=self._data - ) + return await self.async_step_config_storage() return await self._show_config_3(user_input) return await self._show_config_3(user_input) @@ -403,9 +427,8 @@ async def async_step_config_amazon(self, user_input=None): if len(self._errors) == 0: if self._data[CONF_CUSTOM_IMG]: return await self.async_step_config_3() - return self.async_create_entry( - title=self._data[CONF_HOST], data=self._data - ) + return await self.async_step_config_storage() + return await self._show_config_amazon(user_input) return await self._show_config_amazon(user_input) @@ -425,6 +448,33 @@ async def _show_config_amazon(self, user_input): errors=self._errors, ) + async def async_step_config_storage(self, user_input=None): + """Configure form step storage.""" + 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=self._data[CONF_HOST], data=self._data + ) + return await self._show_config_storage(user_input) + + return await self._show_config_storage(user_input) + + async def _show_config_storage(self, user_input): + """Step 3 setup.""" + # Defaults + defaults = { + CONF_STORAGE: DEFAULT_STORAGE, + } + + return self.async_show_form( + step_id="config_storage", + data_schema=_get_schema_step_storage(user_input, defaults), + errors=self._errors, + ) + 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"]) @@ -473,12 +523,7 @@ async def async_step_reconfig_2(self, user_input=None): if self._data[CONF_CUSTOM_IMG]: 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") + return await self.async_step_reconfig_storage() return await self._show_reconfig_2(user_input) @@ -502,12 +547,7 @@ async def async_step_reconfig_3(self, user_input=None): self._data.update(user_input) self._errors, user_input = await _validate_user_input(self._data) if len(self._errors) == 0: - 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.async_step_reconfig_storage() return await self._show_reconfig_3(user_input) @@ -536,6 +576,27 @@ async def async_step_reconfig_amazon(self, user_input=None): if self._data[CONF_CUSTOM_IMG]: return await self.async_step_reconfig_3() + return await self.async_step_reconfig_storage() + + return await self._show_reconfig_amazon(user_input) + + return await self._show_reconfig_amazon(user_input) + + async def _show_reconfig_amazon(self, user_input): + """Step 3 setup.""" + return self.async_show_form( + step_id="reconfig_amazon", + data_schema=_get_schema_step_amazon(user_input, self._data), + errors=self._errors, + ) + + async def async_step_reconfig_storage(self, user_input=None): + """Configure form step storage.""" + 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: self.hass.config_entries.async_update_entry( self._entry, data=self._data ) @@ -543,14 +604,14 @@ async def async_step_reconfig_amazon(self, user_input=None): _LOGGER.debug("%s reconfigured.", DOMAIN) return self.async_abort(reason="reconfigure_successful") - return await self._show_reconfig_amazon(user_input) + return await self._show_reconfig_storage(user_input) - return await self._show_reconfig_amazon(user_input) + return await self._show_reconfig_storage(user_input) - async def _show_reconfig_amazon(self, user_input): + async def _show_reconfig_storage(self, user_input): """Step 3 setup.""" return self.async_show_form( - step_id="reconfig_amazon", - data_schema=_get_schema_step_amazon(user_input, self._data), + step_id="reconfig_storage", + data_schema=_get_schema_step_storage(user_input, self._data), errors=self._errors, ) diff --git a/custom_components/mail_and_packages/const.py b/custom_components/mail_and_packages/const.py index edb6bccf..2736f389 100644 --- a/custom_components/mail_and_packages/const.py +++ b/custom_components/mail_and_packages/const.py @@ -46,6 +46,7 @@ CONF_CAMERA_NAME = "camera_name" CONF_CUSTOM_IMG = "custom_img" CONF_CUSTOM_IMG_FILE = "custom_img_file" +CONF_STORAGE = "storage" CONF_FOLDER = "folder" CONF_PATH = "image_path" CONF_DURATION = "gif_duration" @@ -76,6 +77,7 @@ DEFAULT_CUSTOM_IMG_FILE = "custom_components/mail_and_packages/images/mail_none.gif" DEFAULT_AMAZON_DAYS = 3 DEFAULT_AMAZON_DOMAIN = "amazon.com" +DEFAULT_STORAGE = "custom_components/mail_and_packages/images/" # Amazon AMAZON_DOMAINS = [ diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index 5517cbeb..9203e528 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -78,6 +78,7 @@ CONF_GENERATE_MP4, CONF_IMAP_SECURITY, CONF_VERIFY_SSL, + CONF_STORAGE, DEFAULT_AMAZON_DAYS, OVERLAY, SENSOR_DATA, @@ -158,9 +159,11 @@ def default_image_path( ) -> str: """Return value of the default image path. - Returns the default path based on logic (placeholder for future code) + Returns the default path based on logic """ - # Return the default + storage = config_entry.get(CONF_STORAGE) + if storage: + return storage return "custom_components/mail_and_packages/images/" diff --git a/custom_components/mail_and_packages/strings.json b/custom_components/mail_and_packages/strings.json index 354255fc..fcf3015b 100644 --- a/custom_components/mail_and_packages/strings.json +++ b/custom_components/mail_and_packages/strings.json @@ -1,106 +1,121 @@ { - "config": { - "abort": { - "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.", - "invalid_path": "Please store the images in another directory.", - "ffmpeg_not_found": "Generate MP4 requires ffmpeg", - "amazon_domain": "Invalid forwarding email address.", - "file_not_found": "Image file not found", - "invalid_email_format": "Invalid email address format." - }, - "step": { - "user": { - "description": "Please enter the connection information of your mail server.", - "data": { - "host": "Host", - "password": "Password", - "port": "Port", - "username": "Username", - "verify_ssl": "Verify SSL Cert", - "imap_security": "IMAP Security" - }, - "title": "Mail and Packages (Step 1 of 2)" - }, - "config_2": { - "data": { - "folder": "Mail Folder", - "resources": "Sensors List", - "scan_interval": "Scanning Interval (minutes, minimum 5)", - "image_path": "Image Path", - "gif_duration": "Image Duration (seconds)", - "image_security": "Random Image Filename", - "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", - "generate_mp4": "Create mp4 from images", - "allow_external": "Create image for notification apps", - "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 separate each address with a comma.", - "title": "Mail and Packages (Step 2 of 2)" - }, - "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)" - }, - "config_amazon": { - "data": { - "amazon_domain": "Amazon domain", - "amazon_fwds": "Amazon fowarded email addresses", - "amazon_days": "Days back to check for Amazon emails" - }, - "description": "Please enter the domain Amazon sends email's from (ie: amazon.com or amazon.de)\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", - "title": "Amazon Settings" - }, - "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, minimum 5)", - "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)", - "allow_external": "Create image for notification apps", - "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 separate 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)" - }, - "reconfig_amazon": { - "data": { - "amazon_domain": "Amazon domain", - "amazon_fwds": "Amazon fowarded email addresses", - "amazon_days": "Days back to check for Amazon emails" - }, - "description": "Please enter the domain Amazon sends email's from (ie: amazon.com or amazon.de)\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", - "title": "Amazon Settings" - } - } - } + "config": { + "abort": { + "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.", + "invalid_path": "Please store the images in another directory.", + "ffmpeg_not_found": "Generate MP4 requires ffmpeg", + "amazon_domain": "Invalid forwarding email address.", + "file_not_found": "Image file not found", + "invalid_email_format": "Invalid email address format.", + "path_not_found": "Directory not found" + }, + "step": { + "user": { + "description": "Please enter the connection information of your mail server.", + "data": { + "host": "Host", + "password": "Password", + "port": "Port", + "username": "Username", + "verify_ssl": "Verify SSL Cert", + "imap_security": "IMAP Security" + }, + "title": "Mail and Packages (Step 1 of 2)" + }, + "config_2": { + "data": { + "folder": "Mail Folder", + "resources": "Sensors List", + "scan_interval": "Scanning Interval (minutes, minimum 5)", + "image_path": "Image Path", + "gif_duration": "Image Duration (seconds)", + "image_security": "Random Image Filename", + "imap_timeout": "Time in seconds before connection timeout (seconds, minimum 10)", + "generate_mp4": "Create mp4 from images", + "allow_external": "Create image for notification apps", + "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 separate each address with a comma.", + "title": "Mail and Packages (Step 2 of 2)" + }, + "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)" + }, + "config_amazon": { + "data": { + "amazon_domain": "Amazon domain", + "amazon_fwds": "Amazon fowarded email addresses", + "amazon_days": "Days back to check for Amazon emails" + }, + "description": "Please enter the domain Amazon sends email's from (ie: amazon.com or amazon.de)\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Amazon Settings" + }, + "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, minimum 5)", + "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)", + "allow_external": "Create image for notification apps", + "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 separate 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)" + }, + "reconfig_amazon": { + "data": { + "amazon_domain": "Amazon domain", + "amazon_fwds": "Amazon fowarded email addresses", + "amazon_days": "Days back to check for Amazon emails" + }, + "description": "Please enter the domain Amazon sends email's from (ie: amazon.com or amazon.de)\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", + "title": "Amazon Settings" + }, + "config_storage": { + "data": { + "storage": "Directory to store images" + }, + "description": "Please enter the directory you'd like your images to be stored in.\nThe default is auto populated.", + "title": "Image storage location" + }, + "reconfig_storage": { + "data": { + "storage": "Directory to store images" + }, + "description": "Please enter the directory you'd like your images to be stored in.\nThe default is auto populated.", + "title": "Image storage location" + } + } + } } \ No newline at end of file diff --git a/custom_components/mail_and_packages/translations/ca.json b/custom_components/mail_and_packages/translations/ca.json index 94a37ae9..b845d5a9 100644 --- a/custom_components/mail_and_packages/translations/ca.json +++ b/custom_components/mail_and_packages/translations/ca.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generar MP4 requereix ffmpeg", "amazon_domain": "Adreça de correu electrònic de reenviament no vàlida.", "file_not_found": "No s'ha trobat el fitxer d'imatge", - "invalid_email_format": "Format d'adreça de correu electrònic no vàlid." + "invalid_email_format": "Format d'adreça de correu electrònic no vàlid.", + "path_not_found": "Directori no trobat" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Introduïu el domini des d'on Amazon envia correus electrònics (és a dir: amazon.com o amazon.de)\n\nSi utilitzeu correus electrònics reenviats d'Amazon, separeu cada adreça amb una coma o introduïu (cap) per esborrar aquesta configuració.", "title": "Configuració d'Amazon" + }, + "config_storage": { + "data": { + "storage": "Directori per emmagatzemar imatges" + }, + "description": "Introduïu el directori on voleu que es desin les vostres imatges.\nPer defecte, es completa automàticament.", + "title": "Ubicació de l'emmagatzematge d'imatges" + }, + "reconfig_storage": { + "data": { + "storage": "Directori per emmagatzemar imatges" + }, + "description": "Introduïu el directori on voleu que es desin les vostres imatges.\nPer defecte, es completa automàticament.", + "title": "Ubicació de l'emmagatzematge d'imatges" } } } diff --git a/custom_components/mail_and_packages/translations/de.json b/custom_components/mail_and_packages/translations/de.json index 798e05be..a7dfb689 100644 --- a/custom_components/mail_and_packages/translations/de.json +++ b/custom_components/mail_and_packages/translations/de.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "MP4 erstellen erfordert ffmpeg", "amazon_domain": "Ungültige Weiterleitungs-E-Mail-Adresse.", "file_not_found": "Bilddatei nicht gefunden", - "invalid_email_format": "Ungültiges E-Mail-Adressformat." + "invalid_email_format": "Ungültiges E-Mail-Adressformat.", + "path_not_found": "Verzeichnis nicht gefunden" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Bitte geben Sie die Domain ein, von der Amazon E-Mails sendet (z.B.: amazon.com oder amazon.de)\n\nWenn Sie weitergeleitete E-Mails von Amazon verwenden, trennen Sie bitte jede Adresse mit einem Komma oder geben Sie (keine) ein, um diese Einstellung zu löschen.", "title": "Amazon Einstellungen" + }, + "config_storage": { + "data": { + "storage": "Verzeichnis zum Speichern von Bildern" + }, + "description": "Bitte geben Sie das Verzeichnis ein, in dem Ihre Bilder gespeichert werden sollen.\nStandardmäßig ist es automatisch ausgefüllt.", + "title": "Speicherort für Bilder" + }, + "reconfig_storage": { + "data": { + "storage": "Verzeichnis zum Speichern von Bildern" + }, + "description": "Bitte geben Sie das Verzeichnis ein, in dem Ihre Bilder gespeichert werden sollen.\nStandardmäßig ist es automatisch ausgefüllt.", + "title": "Speicherort für Bilder" } } } diff --git a/custom_components/mail_and_packages/translations/en.json b/custom_components/mail_and_packages/translations/en.json index c9ac6841..fcf3015b 100644 --- a/custom_components/mail_and_packages/translations/en.json +++ b/custom_components/mail_and_packages/translations/en.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generate MP4 requires ffmpeg", "amazon_domain": "Invalid forwarding email address.", "file_not_found": "Image file not found", - "invalid_email_format": "Invalid email address format." + "invalid_email_format": "Invalid email address format.", + "path_not_found": "Directory not found" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Please enter the domain Amazon sends email's from (ie: amazon.com or amazon.de)\n\nIf using Amazon forwarded emails please seperate each address with a comma or enter (none) to clear this setting.", "title": "Amazon Settings" + }, + "config_storage": { + "data": { + "storage": "Directory to store images" + }, + "description": "Please enter the directory you'd like your images to be stored in.\nThe default is auto populated.", + "title": "Image storage location" + }, + "reconfig_storage": { + "data": { + "storage": "Directory to store images" + }, + "description": "Please enter the directory you'd like your images to be stored in.\nThe default is auto populated.", + "title": "Image storage location" } } } diff --git a/custom_components/mail_and_packages/translations/es.json b/custom_components/mail_and_packages/translations/es.json index 80f60852..1bb6a75a 100644 --- a/custom_components/mail_and_packages/translations/es.json +++ b/custom_components/mail_and_packages/translations/es.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generar MP4 requiere ffmpeg", "amazon_domain": "Dirección de correo electrónico de reenvío no válida.", "file_not_found": "Archivo de imagen no encontrado", - "invalid_email_format": "Formato de dirección de correo electrónico no válido." + "invalid_email_format": "Formato de dirección de correo electrónico no válido.", + "path_not_found": "Directorio no encontrado" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Por favor, introduzca el dominio desde el cual Amazon envía correos electrónicos (es decir: amazon.com o amazon.de)\n\nSi utiliza correos electrónicos reenviados por Amazon, separe cada dirección con una coma o introduzca (ninguno) para borrar esta configuración.", "title": "Configuración de Amazon" + }, + "config_storage": { + "data": { + "storage": "Directorio para almacenar imágenes" + }, + "description": "Por favor, introduzca el directorio en el que le gustaría almacenar sus imágenes. \nEl valor predeterminado se rellena automáticamente.", + "title": "Ubicación de almacenamiento de imágenes" + }, + "reconfig_storage": { + "data": { + "storage": "Directorio para almacenar imágenes" + }, + "description": "Por favor, introduzca el directorio en el que le gustaría almacenar sus imágenes. \nEl valor predeterminado se rellena automáticamente.", + "title": "Ubicación de almacenamiento de imágenes" } } } diff --git a/custom_components/mail_and_packages/translations/es_419.json b/custom_components/mail_and_packages/translations/es_419.json index 4df5451b..4a85988d 100644 --- a/custom_components/mail_and_packages/translations/es_419.json +++ b/custom_components/mail_and_packages/translations/es_419.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generar MP4 requiere ffmpeg", "amazon_domain": "Dirección de correo electrónico de reenvío no válida.", "file_not_found": "Archivo de imagen no encontrado", - "invalid_email_format": "Formato de dirección de correo electrónico inválido." + "invalid_email_format": "Formato de dirección de correo electrónico inválido.", + "path_not_found": "Directorio no encontrado" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Por favor, ingrese el dominio desde el cual Amazon envía correos electrónicos (es decir: amazon.com o amazon.de)\n\nSi utiliza correos electrónicos reenviados por Amazon, separe cada dirección con una coma o ingrese (ninguno) para borrar esta configuración.", "title": "Configuración de Amazon" + }, + "config_storage": { + "data": { + "storage": "Directorio para almacenar imágenes" + }, + "description": "Por favor, ingrese el directorio en el que le gustaría almacenar sus imágenes.\nEl predeterminado se llena automáticamente.", + "title": "Ubicación de almacenamiento de imágenes" + }, + "reconfig_storage": { + "data": { + "storage": "Directorio para almacenar imágenes" + }, + "description": "Por favor, ingrese el directorio en el que le gustaría almacenar sus imágenes.\nEl predeterminado se llena automáticamente.", + "title": "Ubicación de almacenamiento de imágenes" } } } diff --git a/custom_components/mail_and_packages/translations/fi.json b/custom_components/mail_and_packages/translations/fi.json index a0e7fb60..42117186 100644 --- a/custom_components/mail_and_packages/translations/fi.json +++ b/custom_components/mail_and_packages/translations/fi.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "MP4:n luominen vaatii ffmpeg:n", "amazon_domain": "Virheellinen edelleenlähetettävä sähköpostiosoite.", "file_not_found": "Kuvatiedostoa ei löydy", - "invalid_email_format": "Virheellinen sähköpostiosoitteen muoto." + "invalid_email_format": "Virheellinen sähköpostiosoitteen muoto.", + "path_not_found": "Hakemistoa ei löydy" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Anna domaini, josta Amazon lähettää sähköposteja (esim: amazon.com tai amazon.de)\n\nJos käytät Amazonin välittämiä sähköposteja, erottele jokainen osoite pilkulla tai kirjoita (none) tyhjentääksesi tämän asetuksen.", "title": "Amazonin asetukset" + }, + "config_storage": { + "data": { + "storage": "Hakemisto kuvien tallentamiseen" + }, + "description": "Anna hakemisto, johon haluat kuviesi tallentuvan.\nOletusarvo täytetään automaattisesti.", + "title": "Kuvien tallennuspaikka" + }, + "reconfig_storage": { + "data": { + "storage": "Hakemisto kuvien tallentamiseen" + }, + "description": "Anna hakemisto, johon haluat kuviesi tallentuvan.\nOletusarvo täytetään automaattisesti.", + "title": "Kuvien tallennuspaikka" } } } diff --git a/custom_components/mail_and_packages/translations/fr.json b/custom_components/mail_and_packages/translations/fr.json index 6e8cc572..4244a473 100644 --- a/custom_components/mail_and_packages/translations/fr.json +++ b/custom_components/mail_and_packages/translations/fr.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Générer MP4 nécessite ffmpeg", "amazon_domain": "Adresse e-mail de transfert invalide.", "file_not_found": "Fichier image non trouvé", - "invalid_email_format": "Format d'adresse e-mail invalide." + "invalid_email_format": "Format d'adresse e-mail invalide.", + "path_not_found": "Répertoire non trouvé" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Veuillez entrer le domaine à partir duquel Amazon envoie des emails (par exemple : amazon.com ou amazon.de)\n\nSi vous utilisez des emails transférés par Amazon, veuillez séparer chaque adresse par une virgule ou entrer (aucun) pour effacer ce paramètre.", "title": "Paramètres Amazon" + }, + "config_storage": { + "data": { + "storage": "Répertoire pour stocker les images" + }, + "description": "Veuillez entrer le répertoire dans lequel vous souhaitez que vos images soient stockées.\nLa valeur par défaut est automatiquement remplie.", + "title": "Emplacement de stockage des images" + }, + "reconfig_storage": { + "data": { + "storage": "Répertoire pour stocker les images" + }, + "description": "Veuillez entrer le répertoire dans lequel vous souhaitez que vos images soient stockées.\nLa valeur par défaut est automatiquement remplie.", + "title": "Emplacement de stockage des images" } } } diff --git a/custom_components/mail_and_packages/translations/hu.json b/custom_components/mail_and_packages/translations/hu.json index 032a64c2..035c0fb1 100644 --- a/custom_components/mail_and_packages/translations/hu.json +++ b/custom_components/mail_and_packages/translations/hu.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Az MP4 generálása ffmpeg-et igényel", "amazon_domain": "Érvénytelen továbbítási e-mail cím.", "file_not_found": "Képfájl nem található", - "invalid_email_format": "Érvénytelen e-mail cím formátum." + "invalid_email_format": "Érvénytelen e-mail cím formátum.", + "path_not_found": "Könyvtár nem található" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Kérjük, adja meg azt a domain-t, ahonnan az Amazon e-maileket küld (pl.: amazon.com vagy amazon.de)\n\nHa az Amazon továbbított e-maileket használ, kérjük, válassza el minden címet vesszővel, vagy írja be, hogy (nincs), hogy törölje ezt a beállítást.", "title": "Amazon beállítások" + }, + "config_storage": { + "data": { + "storage": "Képek tárolására szolgáló könyvtár" + }, + "description": "Kérjük, adja meg azt a könyvtárat, ahová a képeit szeretné tárolni.\nAz alapértelmezett automatikusan kitöltődik.", + "title": "Képtárolási hely" + }, + "reconfig_storage": { + "data": { + "storage": "Képek tárolására szolgáló könyvtár" + }, + "description": "Kérjük, adja meg azt a könyvtárat, ahová a képeit szeretné tárolni.\nAz alapértelmezett automatikusan kitöltődik.", + "title": "Képtárolási hely" } } } diff --git a/custom_components/mail_and_packages/translations/it.json b/custom_components/mail_and_packages/translations/it.json index 5b103d38..ea087d44 100644 --- a/custom_components/mail_and_packages/translations/it.json +++ b/custom_components/mail_and_packages/translations/it.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generare MP4 richiede ffmpeg", "amazon_domain": "Indirizzo email di inoltro non valido.", "file_not_found": "File immagine non trovato", - "invalid_email_format": "Formato dell'indirizzo email non valido." + "invalid_email_format": "Formato dell'indirizzo email non valido.", + "path_not_found": "Directory non trovato" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Inserisci il dominio da cui Amazon invia le email (ad esempio: amazon.com o amazon.de)\n\nSe stai utilizzando email inoltrate da Amazon, separa ogni indirizzo con una virgola o inserisci (nessuno) per cancellare questa impostazione.", "title": "Impostazioni Amazon" + }, + "config_storage": { + "data": { + "storage": "Cartella per memorizzare le immagini" + }, + "description": "Inserisci la directory in cui desideri che le tue immagini vengano memorizzate.\nIl valore predefinito viene popolato automaticamente.", + "title": "Posizione di archiviazione delle immagini" + }, + "reconfig_storage": { + "data": { + "storage": "Cartella per memorizzare le immagini" + }, + "description": "Inserisci la directory in cui desideri che le tue immagini vengano memorizzate.\nIl valore predefinito viene popolato automaticamente.", + "title": "Posizione di archiviazione delle immagini" } } } diff --git a/custom_components/mail_and_packages/translations/ko.json b/custom_components/mail_and_packages/translations/ko.json index 670054a0..525c07fb 100644 --- a/custom_components/mail_and_packages/translations/ko.json +++ b/custom_components/mail_and_packages/translations/ko.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "MP4 생성은 ffmpeg가 필요합니다", "amazon_domain": "잘못된 전달 이메일 주소입니다.", "file_not_found": "이미지 파일을 찾을 수 없습니다", - "invalid_email_format": "잘못된 이메일 주소 형식입니다." + "invalid_email_format": "잘못된 이메일 주소 형식입니다.", + "path_not_found": "디렉토리를 찾을 수 없습니다" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Amazon이 이메일을 보내는 도메인을 입력해 주세요 (예: amazon.com 또는 amazon.de)\n\nAmazon에서 전달된 이메일을 사용하는 경우 각 주소를 쉼표로 구분하거나 이 설정을 지우려면 (none)을 입력하세요.", "title": "아마존 설정" + }, + "config_storage": { + "data": { + "storage": "이미지를 저장할 디렉토리" + }, + "description": "이미지를 저장할 디렉토리를 입력해 주세요.\n기본값은 자동으로 채워집니다.", + "title": "이미지 저장 위치" + }, + "reconfig_storage": { + "data": { + "storage": "이미지를 저장할 디렉토리" + }, + "description": "이미지를 저장할 디렉토리를 입력해 주세요.\n기본값은 자동으로 채워집니다.", + "title": "이미지 저장 위치" } } } diff --git a/custom_components/mail_and_packages/translations/nl.json b/custom_components/mail_and_packages/translations/nl.json index ae81d214..50c4f0ff 100644 --- a/custom_components/mail_and_packages/translations/nl.json +++ b/custom_components/mail_and_packages/translations/nl.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "MP4 genereren vereist ffmpeg", "amazon_domain": "Ongeldig doorstuur e-mailadres.", "file_not_found": "Afbeeldingsbestand niet gevonden", - "invalid_email_format": "Ongeldig e-mailadres formaat." + "invalid_email_format": "Ongeldig e-mailadres formaat.", + "path_not_found": "Map niet gevonden" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Voer het domein in waarvan Amazon e-mails verstuurt (bijv: amazon.com of amazon.de)\n\nAls u doorgestuurde e-mails van Amazon gebruikt, scheid dan elk adres met een komma of voer (geen) in om deze instelling te wissen.", "title": "Amazon Instellingen" + }, + "config_storage": { + "data": { + "storage": "Map om afbeeldingen op te slaan" + }, + "description": "Voer de map in waar u uw afbeeldingen wilt opslaan.\nDe standaard is automatisch ingevuld.", + "title": "Locatie voor afbeeldingsopslag" + }, + "reconfig_storage": { + "data": { + "storage": "Map om afbeeldingen op te slaan" + }, + "description": "Voer de map in waar u uw afbeeldingen wilt opslaan.\nDe standaard is automatisch ingevuld.", + "title": "Locatie voor afbeeldingsopslag" } } } diff --git a/custom_components/mail_and_packages/translations/no.json b/custom_components/mail_and_packages/translations/no.json index 29eecb78..8f1958a1 100644 --- a/custom_components/mail_and_packages/translations/no.json +++ b/custom_components/mail_and_packages/translations/no.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generer MP4 krever ffmpeg", "amazon_domain": "Ugyldig videresendings e-postadresse.", "file_not_found": "Bildefil ikke funnet", - "invalid_email_format": "Ugyldig e-postadresseformat." + "invalid_email_format": "Ugyldig e-postadresseformat.", + "path_not_found": "Mappen ble ikke funnet" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Vennligst skriv inn domenet amazon sender e-poster fra (f.eks: amazon.com eller amazon.de)\n\nHvis du bruker Amazon videresendte e-poster, vennligst skill hver adresse med et komma, eller skriv inn (ingen) for å tømme denne innstillingen.", "title": "Amazon-innstillinger" + }, + "config_storage": { + "data": { + "storage": "Katalog for å lagre bilder" + }, + "description": "Vennligst oppgi mappen du vil at bildene dine skal lagres i.\nStandard er automatisk fylt ut.", + "title": "Bildelagringssted" + }, + "reconfig_storage": { + "data": { + "storage": "Katalog for å lagre bilder" + }, + "description": "Vennligst oppgi mappen du vil at bildene dine skal lagres i.\nStandard er automatisk fylt ut.", + "title": "Bildelagringssted" } } } diff --git a/custom_components/mail_and_packages/translations/pl.json b/custom_components/mail_and_packages/translations/pl.json index 4ea63d21..69b0c345 100644 --- a/custom_components/mail_and_packages/translations/pl.json +++ b/custom_components/mail_and_packages/translations/pl.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generowanie MP4 wymaga ffmpeg", "amazon_domain": "Nieprawidłowy adres e-mail do przekierowania.", "file_not_found": "Nie znaleziono pliku obrazu", - "invalid_email_format": "Nieprawidłowy format adresu e-mail." + "invalid_email_format": "Nieprawidłowy format adresu e-mail.", + "path_not_found": "Katalog nie został znaleziony" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Wprowadź domenę, z której Amazon wysyła e-maile (np. amazon.com lub amazon.de)\n\nJeśli korzystasz z przekierowanych e-maili od Amazon, oddziel każdy adres przecinkiem lub wpisz (brak), aby wyczyścić to ustawienie.", "title": "Ustawienia Amazon" + }, + "config_storage": { + "data": { + "storage": "Katalog do przechowywania obrazów" + }, + "description": "Wprowadź katalog, w którym chciałbyś przechowywać swoje obrazy.\nDomyślnie jest on automatycznie wypełniany.", + "title": "Lokalizacja przechowywania obrazów" + }, + "reconfig_storage": { + "data": { + "storage": "Katalog do przechowywania obrazów" + }, + "description": "Wprowadź katalog, w którym chciałbyś przechowywać swoje obrazy.\nDomyślnie jest on automatycznie wypełniany.", + "title": "Lokalizacja przechowywania obrazów" } } } diff --git a/custom_components/mail_and_packages/translations/pt.json b/custom_components/mail_and_packages/translations/pt.json index fb1236e5..8b9ddc70 100644 --- a/custom_components/mail_and_packages/translations/pt.json +++ b/custom_components/mail_and_packages/translations/pt.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Gerar MP4 requer ffmpeg", "amazon_domain": "Endereço de encaminhamento de email inválido.", "file_not_found": "Arquivo de imagem não encontrado", - "invalid_email_format": "Formato de endereço de email inválido." + "invalid_email_format": "Formato de endereço de email inválido.", + "path_not_found": "Diretório não encontrado" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Por favor, insira o domínio de onde a Amazon envia e-mails (por exemplo: amazon.com ou amazon.de)\n\nSe estiver usando e-mails encaminhados pela Amazon, separe cada endereço com uma vírgula ou insira (nenhum) para limpar essa configuração.", "title": "Configurações da Amazon" + }, + "config_storage": { + "data": { + "storage": "Diretório para armazenar imagens" + }, + "description": "Por favor, insira o diretório em que você gostaria que suas imagens fossem armazenadas.\nO padrão é preenchido automaticamente.", + "title": "Local de armazenamento de imagens" + }, + "reconfig_storage": { + "data": { + "storage": "Diretório para armazenar imagens" + }, + "description": "Por favor, insira o diretório em que você gostaria que suas imagens fossem armazenadas.\nO padrão é preenchido automaticamente.", + "title": "Local de armazenamento de imagens" } } } diff --git a/custom_components/mail_and_packages/translations/pt_BR.json b/custom_components/mail_and_packages/translations/pt_BR.json index d2dd25b9..3255aab2 100644 --- a/custom_components/mail_and_packages/translations/pt_BR.json +++ b/custom_components/mail_and_packages/translations/pt_BR.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Gerar MP4 requer ffmpeg", "amazon_domain": "Endereço de encaminhamento de email inválido.", "file_not_found": "Arquivo de imagem não encontrado", - "invalid_email_format": "Formato de endereço de email inválido." + "invalid_email_format": "Formato de endereço de email inválido.", + "path_not_found": "Diretório não encontrado" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Por favor, insira o domínio do qual a Amazon envia e-mails (por exemplo: amazon.com ou amazon.de)\n\nSe estiver usando e-mails encaminhados pela Amazon, separe cada endereço com uma vírgula ou insira (nenhum) para limpar essa configuração.", "title": "Configurações da Amazon" + }, + "config_storage": { + "data": { + "storage": "Diretório para armazenar imagens" + }, + "description": "Por favor, insira o diretório em que você gostaria que suas imagens fossem armazenadas.\nO padrão é preenchido automaticamente.", + "title": "Local de armazenamento de imagens" + }, + "reconfig_storage": { + "data": { + "storage": "Diretório para armazenar imagens" + }, + "description": "Por favor, insira o diretório em que você gostaria que suas imagens fossem armazenadas.\nO padrão é preenchido automaticamente.", + "title": "Local de armazenamento de imagens" } } } diff --git a/custom_components/mail_and_packages/translations/ru.json b/custom_components/mail_and_packages/translations/ru.json index 92f33c90..53a8ddd3 100644 --- a/custom_components/mail_and_packages/translations/ru.json +++ b/custom_components/mail_and_packages/translations/ru.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Для создания MP4 требуется ffmpeg", "amazon_domain": "Недействительный адрес электронной почты для переадресации.", "file_not_found": "Файл изображения не найден", - "invalid_email_format": "Неверный формат адреса электронной почты." + "invalid_email_format": "Неверный формат адреса электронной почты.", + "path_not_found": "Директория не найдена" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Пожалуйста, введите домен, с которого Amazon отправляет электронные письма (например: amazon.com или amazon.de)\n\nЕсли вы используете переадресованные электронные письма от Amazon, разделите каждый адрес запятой или введите (none), чтобы очистить эту настройку.", "title": "Настройки Amazon" + }, + "config_storage": { + "data": { + "storage": "Каталог для хранения изображений" + }, + "description": "Пожалуйста, введите директорию, в которой вы хотите хранить свои изображения. \nПо умолчанию она заполняется автоматически.", + "title": "Место хранения изображения" + }, + "reconfig_storage": { + "data": { + "storage": "Каталог для хранения изображений" + }, + "description": "Пожалуйста, введите директорию, в которой вы хотите хранить свои изображения. \nПо умолчанию она заполняется автоматически.", + "title": "Место хранения изображения" } } } diff --git a/custom_components/mail_and_packages/translations/sk.json b/custom_components/mail_and_packages/translations/sk.json index 48e492f9..6f768ca9 100644 --- a/custom_components/mail_and_packages/translations/sk.json +++ b/custom_components/mail_and_packages/translations/sk.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Vytvorenie MP4 vyžaduje ffmpeg", "amazon_domain": "Neplatná adresa pre presmerovanie e-mailov.", "file_not_found": "Obrázokový súbor nebol nájdený", - "invalid_email_format": "Neplatný formát e-mailovej adresy." + "invalid_email_format": "Neplatný formát e-mailovej adresy.", + "path_not_found": "Adresár nebol nájdený" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Prosím, zadajte doménu, z ktorej Amazon posiela e-maily (napríklad: amazon.com alebo amazon.de)\n\nAk používate preposlané e-maily od Amazonu, oddelte každú adresu čiarkou alebo zadajte (žiadne) na vymazanie tohto nastavenia.", "title": "Nastavenia Amazon" + }, + "config_storage": { + "data": { + "storage": "Adresár na ukladanie obrázkov" + }, + "description": "Prosím, zadajte adresár, v ktorom chcete ukladať svoje obrázky.\nPredvolená hodnota je automaticky vyplnená.", + "title": "Miesto ukladania obrázkov" + }, + "reconfig_storage": { + "data": { + "storage": "Adresár na ukladanie obrázkov" + }, + "description": "Prosím, zadajte adresár, v ktorom chcete ukladať svoje obrázky.\nPredvolená hodnota je automaticky vyplnená.", + "title": "Miesto ukladania obrázkov" } } } diff --git a/custom_components/mail_and_packages/translations/sl.json b/custom_components/mail_and_packages/translations/sl.json index bd4ad790..37dfc9ef 100644 --- a/custom_components/mail_and_packages/translations/sl.json +++ b/custom_components/mail_and_packages/translations/sl.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Ustvarjanje MP4 zahteva ffmpeg", "amazon_domain": "Neveljaven naslov za preusmerjanje e-pošte.", "file_not_found": "Slikovna datoteka ni najdena", - "invalid_email_format": "Neveljaven format e-poštnega naslova." + "invalid_email_format": "Neveljaven format e-poštnega naslova.", + "path_not_found": "Mapa ni najdena" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Prosimo, vnesite domeno, s katere Amazon pošilja e-pošto (npr.: amazon.com ali amazon.de)\n\nČe uporabljate preusmerjena e-poštna sporočila Amazon, ločite vsak naslov z vejico ali vnesite (noben) za izbris te nastavitve.", "title": "Nastavitve Amazon" + }, + "config_storage": { + "data": { + "storage": "Mapa za shranjevanje slik" + }, + "description": "Prosimo, vnesite imenik, v katerem želite shraniti svoje slike.\nPrivzeto je samodejno izpolnjeno.", + "title": "Lokacija shranjevanja slik" + }, + "reconfig_storage": { + "data": { + "storage": "Mapa za shranjevanje slik" + }, + "description": "Prosimo, vnesite imenik, v katerem želite shraniti svoje slike.\nPrivzeto je samodejno izpolnjeno.", + "title": "Lokacija shranjevanja slik" } } } diff --git a/custom_components/mail_and_packages/translations/sv.json b/custom_components/mail_and_packages/translations/sv.json index 853a3258..7ae0537a 100644 --- a/custom_components/mail_and_packages/translations/sv.json +++ b/custom_components/mail_and_packages/translations/sv.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "Generera MP4 kräver ffmpeg", "amazon_domain": "Ogiltig vidarebefordrings e-postadress.", "file_not_found": "Bildfilen hittades inte", - "invalid_email_format": "Ogiltigt format för e-postadress." + "invalid_email_format": "Ogiltigt format för e-postadress.", + "path_not_found": "Katalogen hittades inte" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "Vänligen ange domänen som Amazon skickar e-postmeddelanden från (t.ex: amazon.com eller amazon.de)\n\nOm du använder Amazon vidarebefordrade e-postmeddelanden, vänligen separera varje adress med ett kommatecken eller ange (ingen) för att rensa denna inställning.", "title": "Amazon-inställningar" + }, + "config_storage": { + "data": { + "storage": "Katalog för att lagra bilder" + }, + "description": "Vänligen ange den katalog du vill att dina bilder ska lagras i.\nStandardinställningen är automatiskt ifylld.", + "title": "Bildlagringsplats" + }, + "reconfig_storage": { + "data": { + "storage": "Katalog för att lagra bilder" + }, + "description": "Vänligen ange den katalog du vill att dina bilder ska lagras i.\nStandardinställningen är automatiskt ifylld.", + "title": "Bildlagringsplats" } } } 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 257142c7..c7edce08 100644 --- a/custom_components/mail_and_packages/translations/zh_Hant_HK.json +++ b/custom_components/mail_and_packages/translations/zh_Hant_HK.json @@ -10,7 +10,8 @@ "ffmpeg_not_found": "生成MP4需要ffmpeg", "amazon_domain": "無效的轉發電郵地址。", "file_not_found": "找不到圖像檔案", - "invalid_email_format": "無效的電郵地址格式。" + "invalid_email_format": "無效的電郵地址格式。", + "path_not_found": "找不到目錄" }, "step": { "user": { @@ -100,6 +101,20 @@ }, "description": "請輸入亞馬遜發送電子郵件的域名(例如:amazon.com或amazon.de)\n\n如果使用亞馬遜轉發的電子郵件,請用逗號分隔每個地址,或輸入(無)以清除此設定。", "title": "Amazon 設定" + }, + "config_storage": { + "data": { + "storage": "儲存圖片的目錄" + }, + "description": "請輸入您希望存儲圖像的目錄。\n預設值會自動填充。", + "title": "圖像儲存位置" + }, + "reconfig_storage": { + "data": { + "storage": "儲存圖片的目錄" + }, + "description": "請輸入您希望存儲圖像的目錄。\n預設值會自動填充。", + "title": "圖像儲存位置" } } } diff --git a/tests/const.py b/tests/const.py index cc46efc6..8bcce29d 100644 --- a/tests/const.py +++ b/tests/const.py @@ -120,6 +120,7 @@ "post_nl_packages", ], "scan_interval": 20, + "storage": ".storage/mail_and_packages/images", "username": "user@fake.email", "verify_ssl": False, } @@ -318,6 +319,7 @@ "zpackages_transit", ], "scan_interval": 20, + "storage": ".storage/mail_and_packages/images", "username": "user@fake.email", "verify_ssl": False, } diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 88f3c131..2149e952 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -15,6 +15,7 @@ CONF_GENERATE_MP4, CONF_IMAP_TIMEOUT, CONF_SCAN_INTERVAL, + CONF_STORAGE, DOMAIN, ) from custom_components.mail_and_packages.helpers import _check_ffmpeg, _test_login @@ -24,7 +25,7 @@ @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,step_id_5,input_5,title,data", [ ( { @@ -83,6 +84,10 @@ { "custom_img_file": "images/test.gif", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -101,6 +106,7 @@ "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -143,6 +149,8 @@ async def test_form( input_3, step_id_4, input_4, + step_id_5, + input_5, title, data, hass, @@ -191,6 +199,12 @@ async def test_form( result["flow_id"], input_4 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_5 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_5 + ) + assert result["type"] == "create_entry" assert result["title"] == title assert result["data"] == data @@ -201,7 +215,7 @@ async def test_form( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,step_id_5,input_5,title,data", [ ( { @@ -260,6 +274,10 @@ async def test_form( { "custom_img_file": "images/test.gif", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -278,6 +296,7 @@ async def test_form( "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -320,6 +339,8 @@ async def test_form_no_fwds( input_3, step_id_4, input_4, + step_id_5, + input_5, title, data, hass, @@ -367,6 +388,11 @@ async def test_form_no_fwds( result = await hass.config_entries.flow.async_configure( result["flow_id"], input_4 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_5 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_5 + ) assert result["type"] == "create_entry" assert result["title"] == title @@ -739,7 +765,7 @@ async def test_form_invalid_ffmpeg( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", [ ( { @@ -794,6 +820,10 @@ async def test_form_invalid_ffmpeg( "amazon_days": 3, "amazon_fwds": "(none)", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -811,6 +841,7 @@ async def test_form_invalid_ffmpeg( "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -851,6 +882,8 @@ async def test_form_index_error( input_2, step_id_3, input_3, + step_id_4, + input_4, title, data, hass, @@ -870,6 +903,8 @@ async def test_form_index_error( ), patch( "custom_components.mail_and_packages.config_flow._check_ffmpeg", return_value=True, + ), patch( + "os.path.exists", return_value=True ), patch( "custom_components.mail_and_packages.async_setup", return_value=True ) as mock_setup, patch( @@ -892,6 +927,13 @@ async def test_form_index_error( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + + assert "error" not in result assert result["type"] == "create_entry" assert result["title"] == title assert result["data"] == data @@ -902,7 +944,7 @@ async def test_form_index_error( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", [ ( { @@ -957,6 +999,10 @@ async def test_form_index_error( "amazon_days": 3, "amazon_fwds": "(none)", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -974,6 +1020,7 @@ async def test_form_index_error( "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -1014,6 +1061,8 @@ async def test_form_index_error_2( input_2, step_id_3, input_3, + step_id_4, + input_4, title, data, hass, @@ -1033,6 +1082,8 @@ async def test_form_index_error_2( ), patch( "custom_components.mail_and_packages.config_flow._check_ffmpeg", return_value=True, + ), patch( + "os.path.exists", return_value=True ), patch( "custom_components.mail_and_packages.async_setup", return_value=True ) as mock_setup, patch( @@ -1055,6 +1106,12 @@ async def test_form_index_error_2( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + assert result["type"] == "create_entry" assert result["title"] == title assert result["data"] == data @@ -1065,7 +1122,7 @@ async def test_form_index_error_2( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", [ ( { @@ -1119,6 +1176,10 @@ async def test_form_index_error_2( "amazon_days": 3, "amazon_fwds": "(none)", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -1136,6 +1197,7 @@ async def test_form_index_error_2( "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -1176,6 +1238,8 @@ async def test_form_mailbox_format2( input_2, step_id_3, input_3, + step_id_4, + input_4, title, data, hass, @@ -1195,6 +1259,8 @@ async def test_form_mailbox_format2( ), patch( "custom_components.mail_and_packages.config_flow._check_ffmpeg", return_value=True, + ), patch( + "os.path.exists", return_value=True ), patch( "custom_components.mail_and_packages.async_setup", return_value=True ) as mock_setup, patch( @@ -1217,6 +1283,12 @@ async def test_form_mailbox_format2( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + assert result["type"] == "create_entry" assert result["title"] == title assert result["data"] == data @@ -1227,7 +1299,7 @@ async def test_form_mailbox_format2( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", [ ( { @@ -1281,6 +1353,10 @@ async def test_form_mailbox_format2( "amazon_days": 3, "amazon_fwds": "(none)", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, @@ -1298,6 +1374,7 @@ async def test_form_mailbox_format2( "imap_security": "SSL", "imap_timeout": 30, "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "amazon_packages", "fedex_delivered", @@ -1338,6 +1415,8 @@ async def test_form_mailbox_format3( input_2, step_id_3, input_3, + step_id_4, + input_4, title, data, hass, @@ -1357,6 +1436,8 @@ async def test_form_mailbox_format3( ), patch( "custom_components.mail_and_packages.config_flow._check_ffmpeg", return_value=True, + ), patch( + "os.path.exists", return_value=True ), patch( "custom_components.mail_and_packages.async_setup", return_value=True ) as mock_setup, patch( @@ -1379,6 +1460,12 @@ async def test_form_mailbox_format3( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + assert result["type"] == "create_entry" assert result["title"] == title assert result["data"] == data @@ -1425,7 +1512,7 @@ async def test_imap_login_error(mock_imap_login_error, caplog): @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4", [ ( { @@ -1480,6 +1567,10 @@ async def test_imap_login_error(mock_imap_login_error, caplog): "amazon_days": 3, "amazon_fwds": "testemail@amazon.com", }, + "config_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, ), ], ) @@ -1490,6 +1581,8 @@ async def test_form_amazon_error( input_2, step_id_3, input_3, + step_id_4, + input_4, mock_imap, hass, caplog, @@ -1507,6 +1600,8 @@ async def test_form_amazon_error( ), patch( "custom_components.mail_and_packages.config_flow._check_ffmpeg", return_value=True, + ), patch( + "os.path.exists", return_value=True ), patch( "custom_components.mail_and_packages.async_setup", return_value=True ) as mock_setup, patch( @@ -1528,6 +1623,11 @@ async def test_form_amazon_error( result = await hass.config_entries.flow.async_configure( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) assert result["type"] == "create_entry" assert ( "Amazon domain found in email: testemail@amazon.com, this may cause errors when searching emails." @@ -1657,15 +1757,15 @@ async def test_form_amazon_error_2( "imap_security": "SSL", "verify_ssl": False, }, - "reconfig_2", + "config_2", { "allow_external": False, - "custom_img": True, + "custom_img": False, "folder": '"INBOX"', "generate_mp4": False, "gif_duration": 5, - "imap_timeout": 120, - "scan_interval": 60, + "imap_timeout": 30, + "scan_interval": 20, "resources": [ "amazon_packages", "fedex_delivered", @@ -1695,22 +1795,22 @@ async def test_form_amazon_error_2( "inpost_pl_packages", ], }, - "reconfig_amazon", + "config_amazon", { "amazon_domain": "amazon.com", "amazon_days": 3, - "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email,amazon@example.com,fake@email%$^&@example.com,bogusemail@testamazon.com", }, - "reconfig_3", + "config_storage", { - "custom_img_file": "images/test.gif", + "storage": "custom_components/mail_and_packages/images/", }, "imap.test.email", { "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", - "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email,amazon@example.com,fake@email%$^&@example.com,bogusemail@testamazon.com", "custom_img": True, "custom_img_file": "images/test.gif", "host": "imap.test.email", @@ -1720,30 +1820,16 @@ async def test_form_amazon_error_2( "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": 120, - "scan_interval": 60, + "imap_timeout": 30, + "scan_interval": 20, + "storage": "custom_components/mail_and_packages/images/", "resources": [ - "amazon_delivered", "amazon_packages", - "auspost_delivered", - "auspost_delivering", - "auspost_packages", - "dhl_delivered", - "dhl_delivering", - "dhl_packages", "fedex_delivered", "fedex_delivering", "fedex_packages", - "inpost_pl_delivered", - "inpost_pl_delivering", - "inpost_pl_packages", "mail_updated", - "poczta_polska_delivering", - "poczta_polska_packages", "ups_delivered", "ups_delivering", "ups_packages", @@ -1753,6 +1839,18 @@ async def test_form_amazon_error_2( "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, }, @@ -1760,7 +1858,7 @@ async def test_form_amazon_error_2( ], ) @pytest.mark.asyncio -async def test_reconfigure( +async def test_form_storage_error( input_1, step_id_2, input_2, @@ -1770,39 +1868,30 @@ async def test_reconfigure( input_4, title, data, - hass: HomeAssistant, - integration, - mock_imap_no_email, - mock_osremove, - mock_osmakedir, - mock_listdir, - mock_update_time, - mock_copy_overlays, - mock_hash_file, - mock_getctime_today, - mock_update, -) -> None: - """Test reconfigure flow.""" - entry = integration + hass, + mock_imap, +): + """Test we get the form.""" + await setup.async_setup_component(hass, "persistent_notification", {}) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + assert result["type"] == "form" + assert result["errors"] == {} with patch( - "custom_components.mail_and_packages.config_flow.path", + "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, - ): - - reconfigure_result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) - assert reconfigure_result["type"] is FlowResultType.FORM - assert reconfigure_result["step_id"] == "reconfigure" - + ), 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: result = await hass.config_entries.flow.async_configure( - reconfigure_result["flow_id"], - input_1, + result["flow_id"], input_1 ) assert result["type"] == "form" assert result["step_id"] == step_id_2 @@ -1816,25 +1905,19 @@ async def test_reconfigure( result = await hass.config_entries.flow.async_configure( result["flow_id"], input_3 ) - assert result["type"] == "form" assert result["step_id"] == step_id_4 result = await hass.config_entries.flow.async_configure( result["flow_id"], input_4 ) - # assert "errors" not in result - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "reconfigure_successful" - await hass.async_block_till_done() - _LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN))) - entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.data.copy() == data + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + assert result["errors"] == {CONF_STORAGE: "path_not_found"} @pytest.mark.parametrize( - "input_1,step_id_2,input_2,step_id_3,input_3,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,step_id_5,input_5,title,data", [ ( { @@ -1855,6 +1938,7 @@ async def test_reconfigure( "imap_timeout": 120, "scan_interval": 60, "resources": [ + "amazon_packages", "fedex_delivered", "fedex_delivering", "fedex_packages", @@ -1871,6 +1955,7 @@ async def test_reconfigure( "dhl_delivered", "dhl_delivering", "dhl_packages", + "amazon_delivered", "auspost_delivered", "auspost_delivering", "auspost_packages", @@ -1881,16 +1966,26 @@ async def test_reconfigure( "inpost_pl_packages", ], }, + "reconfig_amazon", + { + "amazon_domain": "amazon.com", + "amazon_days": 3, + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", + }, "reconfig_3", { "custom_img_file": "images/test.gif", }, + "reconfig_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", - "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", "custom_img": True, "custom_img_file": "images/test.gif", "host": "imap.test.email", @@ -1906,7 +2001,10 @@ async def test_reconfigure( "imap_security": "SSL", "imap_timeout": 120, "scan_interval": 60, + "storage": "custom_components/mail_and_packages/images/", "resources": [ + "amazon_delivered", + "amazon_packages", "auspost_delivered", "auspost_delivering", "auspost_packages", @@ -1938,12 +2036,16 @@ async def test_reconfigure( ], ) @pytest.mark.asyncio -async def test_reconfigure_no_amazon( +async def test_reconfigure( input_1, step_id_2, input_2, step_id_3, input_3, + step_id_4, + input_4, + step_id_5, + input_5, title, data, hass: HomeAssistant, @@ -1993,6 +2095,18 @@ async def test_reconfigure_no_amazon( result["flow_id"], input_3 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + assert result["type"] == "form" + assert result["step_id"] == step_id_5 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_5 + ) + # assert "errors" not in result + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "reconfigure_successful" await hass.async_block_till_done() @@ -2003,7 +2117,7 @@ async def test_reconfigure_no_amazon( @pytest.mark.parametrize( - "input_1,step_id_2,input_2,title,data", + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", [ ( { @@ -2017,7 +2131,7 @@ async def test_reconfigure_no_amazon( "reconfig_2", { "allow_external": False, - "custom_img": False, + "custom_img": True, "folder": '"INBOX"', "generate_mp4": False, "gif_duration": 5, @@ -2050,13 +2164,22 @@ async def test_reconfigure_no_amazon( "inpost_pl_packages", ], }, + "reconfig_3", + { + "custom_img_file": "images/test.gif", + }, + "reconfig_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, "imap.test.email", { "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", - "custom_img": False, + "custom_img": True, + "custom_img_file": "images/test.gif", "host": "imap.test.email", "port": 993, "username": "test@test.email", @@ -2070,6 +2193,7 @@ async def test_reconfigure_no_amazon( "imap_security": "SSL", "imap_timeout": 120, "scan_interval": 60, + "storage": "custom_components/mail_and_packages/images/", "resources": [ "auspost_delivered", "auspost_delivering", @@ -2102,10 +2226,14 @@ async def test_reconfigure_no_amazon( ], ) @pytest.mark.asyncio -async def test_reconfigure_no_amazon_no_custom_image( +async def test_reconfigure_no_amazon( input_1, step_id_2, input_2, + step_id_3, + input_3, + step_id_4, + input_4, title, data, hass: HomeAssistant, @@ -2149,6 +2277,18 @@ async def test_reconfigure_no_amazon_no_custom_image( result["flow_id"], input_2 ) + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_3 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "reconfigure_successful" await hass.async_block_till_done() @@ -2156,3 +2296,567 @@ async def test_reconfigure_no_amazon_no_custom_image( _LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN))) entry = hass.config_entries.async_entries(DOMAIN)[0] assert entry.data.copy() == data + + +@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, + }, + "reconfig_2", + { + "allow_external": False, + "custom_img": False, + "folder": '"INBOX"', + "generate_mp4": False, + "gif_duration": 5, + "imap_timeout": 120, + "scan_interval": 60, + "resources": [ + "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", + "auspost_delivered", + "auspost_delivering", + "auspost_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + ], + }, + "reconfig_storage", + { + "storage": ".storage/mail_and_packages/images", + }, + "imap.test.email", + { + "allow_external": False, + "amazon_days": 3, + "amazon_domain": "amazon.com", + "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", + "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": 120, + "scan_interval": 60, + "storage": ".storage/mail_and_packages/images", + "resources": [ + "auspost_delivered", + "auspost_delivering", + "auspost_packages", + "dhl_delivered", + "dhl_delivering", + "dhl_packages", + "fedex_delivered", + "fedex_delivering", + "fedex_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "mail_updated", + "poczta_polska_delivering", + "poczta_polska_packages", + "ups_delivered", + "ups_delivering", + "ups_packages", + "usps_delivered", + "usps_delivering", + "usps_mail", + "usps_packages", + "zpackages_delivered", + "zpackages_transit", + ], + "verify_ssl": False, + }, + ), + ], +) +@pytest.mark.asyncio +async def test_reconfigure_no_amazon_no_custom_image( + input_1, + step_id_2, + input_2, + step_id_3, + input_3, + title, + data, + hass: HomeAssistant, + integration, + mock_imap_no_email, + mock_osremove, + mock_osmakedir, + mock_listdir, + mock_update_time, + mock_copy_overlays, + mock_hash_file, + mock_getctime_today, + mock_update, +) -> None: + """Test reconfigure flow.""" + entry = integration + + with patch( + "custom_components.mail_and_packages.config_flow.path", + return_value=True, + ): + + reconfigure_result = await hass.config_entries.flow.async_init( + DOMAIN, + context={ + "source": config_entries.SOURCE_RECONFIGURE, + "entry_id": entry.entry_id, + }, + ) + assert reconfigure_result["type"] is FlowResultType.FORM + assert reconfigure_result["step_id"] == "reconfigure" + + result = await hass.config_entries.flow.async_configure( + reconfigure_result["flow_id"], + input_1, + ) + assert result["type"] == "form" + assert result["step_id"] == step_id_2 + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_2 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_3 + ) + + assert result["type"] is FlowResultType.ABORT + assert result["reason"] == "reconfigure_successful" + await hass.async_block_till_done() + + _LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN))) + entry = hass.config_entries.async_entries(DOMAIN)[0] + assert entry.data.copy() == data + + +@pytest.mark.parametrize( + "input_1,step_id_2,input_2,step_id_3,input_3,step_id_4,input_4,title,data", + [ + ( + { + "host": "imap.test.email", + "port": "993", + "username": "test@test.email", + "password": "notarealpassword", + "imap_security": "SSL", + "verify_ssl": False, + }, + "reconfig_2", + { + "allow_external": False, + "custom_img": False, + "folder": '"INBOX"', + "generate_mp4": False, + "gif_duration": 5, + "imap_timeout": 120, + "scan_interval": 60, + "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", + ], + }, + "reconfig_amazon", + { + "amazon_domain": "amazon.com", + "amazon_days": 3, + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", + }, + "reconfig_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, + "imap.test.email", + { + "allow_external": False, + "amazon_days": 3, + "amazon_domain": "amazon.com", + "amazon_fwds": "fakeuser@test.email,fakeuser2@test.email", + "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": 120, + "scan_interval": 60, + "storage": "custom_components/mail_and_packages/images/", + "resources": [ + "amazon_delivered", + "amazon_packages", + "auspost_delivered", + "auspost_delivering", + "auspost_packages", + "dhl_delivered", + "dhl_delivering", + "dhl_packages", + "fedex_delivered", + "fedex_delivering", + "fedex_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "mail_updated", + "poczta_polska_delivering", + "poczta_polska_packages", + "ups_delivered", + "ups_delivering", + "ups_packages", + "usps_delivered", + "usps_delivering", + "usps_mail", + "usps_packages", + "zpackages_delivered", + "zpackages_transit", + ], + "verify_ssl": False, + }, + ), + ], +) +@pytest.mark.asyncio +async def test_reconfig_no_cust_img( + input_1, + step_id_2, + input_2, + step_id_3, + input_3, + step_id_4, + input_4, + title, + data, + hass: HomeAssistant, + integration, + mock_imap_no_email, + mock_osremove, + mock_osmakedir, + mock_listdir, + mock_update_time, + mock_copy_overlays, + mock_hash_file, + mock_getctime_today, + mock_update, +) -> None: + """Test reconfigure flow.""" + entry = integration + + with patch( + "custom_components.mail_and_packages.config_flow.path", + return_value=True, + ): + + reconfigure_result = await hass.config_entries.flow.async_init( + DOMAIN, + context={ + "source": config_entries.SOURCE_RECONFIGURE, + "entry_id": entry.entry_id, + }, + ) + assert reconfigure_result["type"] is FlowResultType.FORM + assert reconfigure_result["step_id"] == "reconfigure" + + result = await hass.config_entries.flow.async_configure( + reconfigure_result["flow_id"], + input_1, + ) + assert result["type"] == "form" + assert result["step_id"] == step_id_2 + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_2 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_3 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_4 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_4 + ) + + assert result["type"] is FlowResultType.ABORT + assert result["reason"] == "reconfigure_successful" + await hass.async_block_till_done() + + _LOGGER.debug("Entries: %s", len(hass.config_entries.async_entries(DOMAIN))) + entry = hass.config_entries.async_entries(DOMAIN)[0] + assert entry.data.copy() == data + + +@pytest.mark.parametrize( + "input_1,step_id_2,input_2,step_id_3,input_3", + [ + ( + { + "host": "imap.test.email", + "port": "993", + "username": "test@test.email", + "password": "notarealpassword", + "imap_security": "SSL", + "verify_ssl": False, + }, + "reconfig_2", + { + "allow_external": False, + "custom_img": False, + "folder": '"INBOX"', + "generate_mp4": False, + "gif_duration": 5, + "imap_timeout": 120, + "scan_interval": 60, + "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", + ], + }, + "reconfig_amazon", + { + "amazon_domain": "amazon.com", + "amazon_days": 3, + "amazon_fwds": "amazon.com", + }, + ), + ], +) +@pytest.mark.asyncio +async def test_reconfig_amazon_error( + input_1, + step_id_2, + input_2, + step_id_3, + input_3, + hass: HomeAssistant, + integration, + mock_imap_no_email, + mock_osremove, + mock_osmakedir, + mock_listdir, + mock_update_time, + mock_copy_overlays, + mock_hash_file, + mock_getctime_today, + mock_update, + caplog, +) -> None: + """Test reconfigure flow.""" + entry = integration + + with patch( + "custom_components.mail_and_packages.config_flow.path", + return_value=True, + ): + + reconfigure_result = await hass.config_entries.flow.async_init( + DOMAIN, + context={ + "source": config_entries.SOURCE_RECONFIGURE, + "entry_id": entry.entry_id, + }, + ) + assert reconfigure_result["type"] is FlowResultType.FORM + assert reconfigure_result["step_id"] == "reconfigure" + + result = await hass.config_entries.flow.async_configure( + reconfigure_result["flow_id"], + input_1, + ) + assert result["type"] == "form" + assert result["step_id"] == step_id_2 + + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_2 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_3 + ) + + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == step_id_3 + assert "Missing '@' in email address: amazon.com" in caplog.text + assert result["errors"] == {CONF_AMAZON_FWDS: "invalid_email_format"} + + +@pytest.mark.parametrize( + "input_1,step_id_2,input_2,step_id_3,input_3", + [ + ( + { + "host": "imap.test.email", + "port": "993", + "username": "test@test.email", + "password": "notarealpassword", + "imap_security": "SSL", + "verify_ssl": False, + }, + "reconfig_2", + { + "allow_external": False, + "custom_img": False, + "folder": '"INBOX"', + "generate_mp4": False, + "gif_duration": 5, + "imap_timeout": 30, + "scan_interval": 20, + "resources": [ + "mail_updated", + "usps_delivered", + "usps_delivering", + "usps_mail", + "usps_packages", + "zpackages_delivered", + "zpackages_transit", + ], + }, + "reconfig_storage", + { + "storage": "custom_components/mail_and_packages/images/", + }, + ), + ], +) +@pytest.mark.asyncio +async def test_reconfig_storage_error( + input_1, + step_id_2, + input_2, + step_id_3, + input_3, + hass: HomeAssistant, + integration, + mock_imap_no_email, +): + """Test we get the form.""" + entry = integration + + reconfigure_result = await hass.config_entries.flow.async_init( + DOMAIN, + context={ + "source": config_entries.SOURCE_RECONFIGURE, + "entry_id": entry.entry_id, + }, + ) + assert reconfigure_result["type"] is FlowResultType.FORM + assert reconfigure_result["step_id"] == "reconfigure" + + result = await hass.config_entries.flow.async_configure( + reconfigure_result["flow_id"], + input_1, + ) + assert result["type"] == "form" + assert result["step_id"] == step_id_2 + + result = await hass.config_entries.flow.async_configure(result["flow_id"], input_2) + + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + + with patch( + "custom_components.mail_and_packages.config_flow._validate_user_input", + return_value=({CONF_STORAGE: "path_not_found"}, input_3), + ): + result = await hass.config_entries.flow.async_configure( + result["flow_id"], input_3 + ) + + assert result["type"] == "form" + assert result["step_id"] == step_id_3 + assert result["errors"] == {CONF_STORAGE: "path_not_found"} diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 9f0662bc..38bab85c 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -32,6 +32,7 @@ resize_images, selectfolder, update_time, + default_image_path, ) from tests.const import ( FAKE_CONFIG_DATA,