diff --git a/custom_components/mail_and_packages/config_flow.py b/custom_components/mail_and_packages/config_flow.py index cc2a1468..9910dd9b 100644 --- a/custom_components/mail_and_packages/config_flow.py +++ b/custom_components/mail_and_packages/config_flow.py @@ -60,25 +60,17 @@ async def _check_amazon_forwards(forwards: str) -> tuple: Returns tuple: dict of errors, list of email addresses """ - amazon_forwards_list = [] + amazon_forwards_list = forwards errors = [] # Check for amazon domains if "@amazon" in forwards: errors.append("amazon_domain") - # Check for commas - 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: - amazon_forwards_list.append(forwards) - if len(errors) == 0: errors.append("ok") diff --git a/tests/conftest.py b/tests/conftest.py index 4799b60a..e6828776 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,7 +14,11 @@ from aioresponses import aioresponses from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.mail_and_packages.const import CONF_AMAZON_DOMAIN, DOMAIN +from custom_components.mail_and_packages.const import ( + CONF_AMAZON_DOMAIN, + CONFIG_VERSION, + DOMAIN, +) from tests.const import ( FAKE_CONFIG_DATA, FAKE_CONFIG_DATA_AMAZON_FWD_STRING, @@ -52,7 +56,10 @@ def mock_update(): async def integration_fixture(hass): """Set up the mail_and_packages integration.""" entry = MockConfigEntry( - domain=DOMAIN, title="imap.test.email", data=FAKE_CONFIG_DATA + domain=DOMAIN, + title="imap.test.email", + data=FAKE_CONFIG_DATA, + version=CONFIG_VERSION, ) entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) diff --git a/tests/const.py b/tests/const.py index e7251345..0f3e3567 100644 --- a/tests/const.py +++ b/tests/const.py @@ -65,7 +65,7 @@ "gif_duration": 5, "host": "imap.test.email", "image_name": "mail_today.gif", - "image_path": "/config/www/mail_and_packages/", + "image_path": "custom_components/mail_and_packages/images/", "image_security": True, "imap_security": "SSL", "imap_timeout": 30, @@ -256,7 +256,7 @@ "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", - "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_config_flow.py b/tests/test_config_flow.py index 7dd752d9..5d574e11 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,8 +1,7 @@ """ Test Mail and Packages config flow """ -from unittest.mock import patch - import logging +from unittest.mock import patch import pytest from homeassistant import config_entries, setup @@ -89,7 +88,7 @@ "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", "custom_img": True, "custom_img_file": "images/test.gif", "host": "imap.test.email", @@ -1598,7 +1597,7 @@ async def test_form_amazon_error( "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", "custom_img": True, "custom_img_file": "images/test.gif", "host": "imap.test.email", @@ -1778,7 +1777,7 @@ async def test_reconfigure( "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", - "amazon_fwds": ["fakeuser@fake.email", "fakeuser2@fake.email"], + "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", "custom_img": True, "custom_img_file": "images/test.gif", "host": "imap.test.email", @@ -1943,7 +1942,7 @@ async def test_reconfigure_no_amazon( "allow_external": False, "amazon_days": 3, "amazon_domain": "amazon.com", - "amazon_fwds": ["fakeuser@fake.email", "fakeuser2@fake.email"], + "amazon_fwds": "fakeuser@fake.email, fakeuser2@fake.email", "custom_img": False, "host": "imap.test.email", "port": 993, diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 38e1ab38..9667f1a1 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -799,7 +799,10 @@ async def test_amazon_search_delivered( result = amazon_search( mock_imap_amazon_delivered, "test/path", hass, "testfilename.jpg", "amazon.com" ) - assert "Amazon email search address: ['order-update@amazon.com', 'update-bestelling@amazon.com']" in caplog.text + assert ( + "Amazon email search address: ['order-update@amazon.com', 'update-bestelling@amazon.com']" + in caplog.text + ) assert result == 7 assert mock_download_img.called