From 1e8abf5f9da4dc01f5fcd35738286e18d5987ff4 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 25 Jul 2022 09:52:26 -0700 Subject: [PATCH] fix: adjust amazon forward config processing --- custom_components/mail_and_packages/config_flow.py | 6 +++++- custom_components/mail_and_packages/const.py | 2 +- custom_components/mail_and_packages/helpers.py | 2 +- tests/test_config_flow.py | 2 +- tox.ini | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/custom_components/mail_and_packages/config_flow.py b/custom_components/mail_and_packages/config_flow.py index 4c797c07..10243dd3 100644 --- a/custom_components/mail_and_packages/config_flow.py +++ b/custom_components/mail_and_packages/config_flow.py @@ -64,8 +64,12 @@ async def _check_amazon_forwards(forwards: str) -> tuple: if "," in forwards: amazon_forwards_list = forwards.split(",") + # No forwards + elif forwards in ["", "(none)", ""]: + amazon_forwards_list = [] + # If only one address append it to the list - elif forwards != "" or forwards: + elif forwards: amazon_forwards_list.append(forwards) if len(errors) == 0: diff --git a/custom_components/mail_and_packages/const.py b/custom_components/mail_and_packages/const.py index 565bddcf..20feb7bb 100644 --- a/custom_components/mail_and_packages/const.py +++ b/custom_components/mail_and_packages/const.py @@ -65,7 +65,7 @@ DEFAULT_GIF_DURATION = 5 DEFAULT_SCAN_INTERVAL = 5 DEFAULT_GIF_FILE_NAME = "mail_today.gif" -DEFAULT_AMAZON_FWDS = '""' +DEFAULT_AMAZON_FWDS = "(none)" DEFAULT_ALLOW_EXTERNAL = False DEFAULT_CUSTOM_IMG = False DEFAULT_CUSTOM_IMG_FILE = "custom_components/mail_and_packages/images/mail_none.gif" diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index b5d76070..31b82f33 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -1186,7 +1186,7 @@ def amazon_hub(account: Type[imaplib.IMAP4_SSL], fwds: Optional[str] = None) -> def amazon_exception( - account: Type[imaplib.IMAP4_SSL], fwds: Optional[str] = None + account: Type[imaplib.IMAP4_SSL], fwds: Optional[list] = None ) -> dict: """Find Amazon exception emails. diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 8c20255d..8eea2bf6 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -2030,7 +2030,7 @@ async def test_options_flow_mailbox_format2( { "allow_external": False, "amazon_days": 3, - "amazon_fwds": ['""'], + "amazon_fwds": [], "custom_img": False, "host": "imap.test.email", "port": 993, diff --git a/tox.ini b/tox.ini index dea061dc..1130492d 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,8 @@ ignore_basepython_conflict = True [gh-actions] python = - 3.9: py39, lint, mypy - 3.10: py310 + 3.9: py39 + 3.10: py310, lint, mypy [testenv] pip_version = pip>=21.0,<22.1