diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000..e304a9a5 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,60 @@ +## Developing with Visual Studio Code + devcontainer + +The easiest way to get started with custom integration development is to use Visual Studio Code with devcontainers. This approach will create a preconfigured development environment with all the tools you need. + +In the container you will have a dedicated Home Assistant core instance running with your custom component code. You can configure this instance by updating the `./devcontainer/configuration.yaml` file. + +**Prerequisites** + +- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +- Docker + - For Linux, macOS, or Windows 10 Pro/Enterprise/Education use the [current release version of Docker](https://docs.docker.com/install/) + - Windows 10 Home requires [WSL 2](https://docs.microsoft.com/windows/wsl/wsl2-install) and the current Edge version of Docker Desktop (see instructions [here](https://docs.docker.com/docker-for-windows/wsl-tech-preview/)). This can also be used for Windows Pro/Enterprise/Education. +- [Visual Studio code](https://code.visualstudio.com/) +- [Remote - Containers (VSC Extension)][extension-link] + +[More info about requirements and devcontainer in general](https://code.visualstudio.com/docs/remote/containers#_getting-started) + +[extension-link]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers + +**Getting started:** + +1. Fork the repository. +2. Clone the repository to your computer. +3. Open the repository using Visual Studio code. + +When you open this repository with Visual Studio code you are asked to "Reopen in Container", this will start the build of the container. + +_If you don't see this notification, open the command palette and select `Remote-Containers: Reopen Folder in Container`._ + +### Tasks + +The devcontainer comes with some useful tasks to help you with development, you can start these tasks by opening the command palette and select `Tasks: Run Task` then select the task you want to run. + +When a task is currently running (like `Run Home Assistant on port 9123` for the docs), it can be restarted by opening the command palette and selecting `Tasks: Restart Running Task`, then select the task you want to restart. + +The available tasks are: + +Task | Description +-- | -- +Run Home Assistant on port 9123 | Launch Home Assistant with your custom component code and the configuration defined in `.devcontainer/configuration.yaml`. +Run Home Assistant configuration against /config | Check the configuration. +Upgrade Home Assistant to latest dev | Upgrade the Home Assistant core version in the container to the latest version of the `dev` branch. +Install a specific version of Home Assistant | Install a specific version of Home Assistant core in the container. + +### Step by Step debugging + +With the development container, +you can test your custom component in Home Assistant with step by step debugging. + +You need to modify the `configuration.yaml` file in `.devcontainer` folder +by uncommenting the line: + +```yaml +# debugpy: +``` + +Then launch the task `Run Home Assistant on port 9123`, and launch the debugger +with the existing debugging configuration `Python: Attach Local`. + +For more information, look at [the Remote Python Debugger integration documentation](https://www.home-assistant.io/integrations/debugpy/). diff --git a/.devcontainer/configuration.yaml b/.devcontainer/configuration.yaml new file mode 100644 index 00000000..3f5b5aef --- /dev/null +++ b/.devcontainer/configuration.yaml @@ -0,0 +1,9 @@ +default_config: + +logger: + default: info + logs: + custom_components.mail_and_packages: debug + +# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/) +debugpy: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..f36c2ce1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +// See https://aka.ms/vscode-remote/devcontainer.json for format details. +{ + "image": "ludeeus/container:integration-debian", + "name": "Mail And Packages integration development", + "context": "..", + "appPort": [ + "9123:8123", + "5678:5678" + ], + "postCreateCommand": "container install", + "extensions": [ + "ms-python.python", + "github.vscode-pull-request-github", + "ryanluker.vscode-coverage-gutters", + "ms-python.vscode-pylance" + ], + "settings": { + "files.eol": "\n", + "editor.tabSize": 4, + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/bin/python3", + "python.analysis.autoSearchPaths": false, + "python.linting.pylintEnabled": true, + "python.linting.enabled": true, + "python.formatting.provider": "black", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true + } +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..555a62b8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + // Example of attaching to local debug server + "name": "Python: Attach Local", + "type": "python", + "request": "attach", + "port": 5678, + "host": "localhost", + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "." + } + ] + }, + { + // Example of attaching to my production server + "name": "Python: Attach Remote", + "type": "python", + "request": "attach", + "port": 5678, + "host": "homeassistant.local", + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "/usr/src/homeassistant" + } + ] + } + ] + } + \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..7ab4ba81 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run Home Assistant on port 9123", + "type": "shell", + "command": "container start", + "problemMatcher": [] + }, + { + "label": "Run Home Assistant configuration against /config", + "type": "shell", + "command": "container check", + "problemMatcher": [] + }, + { + "label": "Upgrade Home Assistant to latest dev", + "type": "shell", + "command": "container install", + "problemMatcher": [] + }, + { + "label": "Install a specific version of Home Assistant", + "type": "shell", + "command": "container set-version", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/custom_components/mail_and_packages/const.py b/custom_components/mail_and_packages/const.py index 9b7291c3..f9a48149 100644 --- a/custom_components/mail_and_packages/const.py +++ b/custom_components/mail_and_packages/const.py @@ -224,35 +224,35 @@ "royal_packages": {}, "royal_tracking": {"pattern": ["[A-Za-z]{2}[0-9]{9}GB"]}, # Poczta Polska SA - "pocztapolska_delivered": {}, - "pocztapolska_delivering": { + "poczta_polska_delivered": {}, + "poczta_polska_delivering": { "email": ["informacja@poczta-polska.pl", "powiadomienia@allegromail.pl"], "subject": ["Poczta Polska S.A. eINFO"], }, - "pocztapolska_packages": {}, - "pocztapolska_tracking": { + "poczta_polska_packages": {}, + "poczta_polska_tracking": { # http://emonitoring.poczta-polska.pl/?numer=00359007738913296666 "pattern": ["\\d{20}"] }, # InPost.pl - "inpostpl_delivered": { + "inpost_pl_delivered": { "email": ["powiadomienia@inpost.pl", "powiadomienia@allegromail.pl"], "subject": [ "InPost - Potwierdzenie odbioru przesyłki", "InPost - Paczka umieszczona w Paczkomacie", ], }, - "inpostpl_delivering": { - "email": ["powiadomienia@inpost.pl"], + "inpost_pl_delivering": { + "email": ["powiadomienia@inpost.pl", "powiadomienia@allegromail.pl"], "subject": ["paczka jest w drodze", "jest już prawie u Ciebie"], }, - "inpostpl_packages": {}, - "inpostpl_tracking": { + "inpost_pl_packages": {}, + "inpost_pl_tracking": { # https://inpost.pl/sledzenie-przesylek?number=520113017830399002575123 "pattern": ["\\d{24}"] }, # DPD Poland - "dpdcompl_delivered": { + "dpd_com_pl_delivered": { "email": [ "KurierDPD0@dpd.com.pl", "KurierDPD1@dpd.com.pl", @@ -265,12 +265,13 @@ "KurierDPD8@dpd.com.pl", "KurierDPD9@dpd.com.pl", "KurierDPD10@dpd.com.pl", + "powiadomienia@allegromail.pl", ], "subject": [ "została doręczona", ], }, - "dpdcompl_delivering": { + "dpd_com_pl_delivering": { "email": [ "KurierDPD0@dpd.com.pl", "KurierDPD1@dpd.com.pl", @@ -283,26 +284,38 @@ "KurierDPD8@dpd.com.pl", "KurierDPD9@dpd.com.pl", "KurierDPD10@dpd.com.pl", + "powiadomienia@allegromail.pl", + ], + "subject": [ + "Bezpieczne_dor=C4=99czenie_Twojej_paczki", + "Bezpieczne doręczenie", + "przesyłka została nadana", ], - "subject": ["Bezpieczne doręczenie"], - "body": ["Dziś doręczamy"], + "body": ["Dzi=C5=9B dor=C4=99czamy", "DPD Polska"], }, - "dpdcompl_packages": {}, - "dpdcompl_tracking": { + "dpd_com_pl_packages": {}, + "dpd_com_pl_tracking": { # https://tracktrace.dpd.com.pl/parcelDetails?p1=13490015284111 "pattern": ["\\d{13}[A-Z0-9]{1,2}"], }, # GLS "gls_delivered": { - "email": ["noreply@gls-group.eu"], + "email": [ + "noreply@gls-group.eu", + "powiadomienia@allegromail.pl", + ], "subject": [ "informacja o dostawie", ], "body": ["została dzisiaj dostarczona"], }, "gls_delivering": { - "email": ["noreply@gls-group.eu"], + "email": [ + "noreply@gls-group.eu", + "powiadomienia@allegromail.pl", + ], "subject": ["paczka w drodze"], + "body": ["Zespół GLS"], }, "gls_packages": {}, "gls_tracking": { @@ -527,71 +540,77 @@ key="auspost_packages", ), # Poczta Polska SA - "pocztapolska_delivering": SensorEntityDescription( - name="Poczta Polska SA Packages Delivering", + # "poczta_polska_delivered": SensorEntityDescription( + # name="Poczta Polska Delivered", + # native_unit_of_measurement="package(s)", + # icon="mdi:package-variant", + # key="poczta_polska_delivered", + # ), + "poczta_polska_delivering": SensorEntityDescription( + name="Mail Poczta Polska Delivering", native_unit_of_measurement="package(s)", icon="mdi:truck-delivery", - key="pocztapolska_delivering", + key="poczta_polska_delivering", ), - "pocztapolska_packages": SensorEntityDescription( - name="Poczta Polska SA Packages", + "poczta_polska_packages": SensorEntityDescription( + name="Mail Poczta Polska Packages", native_unit_of_measurement="package(s)", icon="mdi:package-variant-closed", - key="pocztapolska_packages", + key="poczta_polska_packages", ), - "inpostpl_delivering": SensorEntityDescription( - name="InPost.pl Packages Delivering", + # InPost.pl + "inpost_pl_delivering": SensorEntityDescription( + name="Mail InPost.pl Delivering", native_unit_of_measurement="package(s)", icon="mdi:truck-delivery", - key="inpostpl_delivering", + key="inpost_pl_delivering", ), - # InPost.pl - "inpostpl_delivered": SensorEntityDescription( - name="InPost.pl Packages Delivered", + "inpost_pl_delivered": SensorEntityDescription( + name="Mail InPost.pl Delivered", native_unit_of_measurement="package(s)", icon="mdi:package-variant", - key="inpostpl_delivered", + key="inpost_pl_delivered", ), - "inpostpl_packages": SensorEntityDescription( - name="InPost.pl Packages", + "inpost_pl_packages": SensorEntityDescription( + name="Mail InPost.pl Packages", native_unit_of_measurement="package(s)", icon="mdi:package-variant-closed", - key="inpostpl_packages", + key="inpost_pl_packages", ), # DPD Poland - "dpdcompl_delivering": SensorEntityDescription( - name="DPD.com.pl Packages Delivering", + "dpd_com_pl_delivering": SensorEntityDescription( + name="Mail DPD.com.pl Delivering", native_unit_of_measurement="package(s)", icon="mdi:truck-delivery", - key="dpdcompl_delivering", + key="dpd_com_pl_delivering", ), - "dpdcompl_delivered": SensorEntityDescription( - name="DPD.com.pl Packages Delivered", + "dpd_com_pl_delivered": SensorEntityDescription( + name="Mail DPD.com.pl Delivered", native_unit_of_measurement="package(s)", icon="mdi:package-variant", - key="dpdcompl_delivered", + key="dpd_com_pl_delivered", ), - "dpdcompl_packages": SensorEntityDescription( - name="DPD.com.pl Packages", + "dpd_com_pl_packages": SensorEntityDescription( + name="Mail DPD.com.pl Packages", native_unit_of_measurement="package(s)", icon="mdi:package-variant-closed", - key="dpdcompl_packages", + key="dpd_com_pl_packages", ), # GLS "gls_delivering": SensorEntityDescription( - name="GLS Packages Delivering", + name="Mail GLS Delivering", native_unit_of_measurement="package(s)", icon="mdi:truck-delivery", key="gls_delivering", ), "gls_delivered": SensorEntityDescription( - name="GLS Packages Delivered", + name="Mail GLS Delivered", native_unit_of_measurement="package(s)", icon="mdi:package-variant", - key="dpdcompl_delivered", + key="dpd_com_pl_delivered", ), "gls_packages": SensorEntityDescription( - name="GLS Packages", + name="Mail GLS Packages", native_unit_of_measurement="package(s)", icon="mdi:package-variant-closed", key="gls_packages", @@ -649,7 +668,8 @@ "hermes", "royal", "auspost", - "inpostpl", - "dpdcompl", + "poczta_polska", + "inpost_pl", + "dpd_com_pl", "gls", ] diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index 11dbb3cf..d067eecc 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -380,12 +380,12 @@ def fetch( count[sensor] = info[ATTR_COUNT] count[AMAZON_EXCEPTION_ORDER] = info[ATTR_ORDER] elif "_packages" in sensor: - prefix = sensor.split("_")[0] + prefix = sensor.replace("_packages", "") delivering = fetch(hass, config, account, data, f"{prefix}_delivering") delivered = fetch(hass, config, account, data, f"{prefix}_delivered") count[sensor] = delivering + delivered elif "_delivering" in sensor: - prefix = sensor.split("_")[0] + prefix = sensor.replace("_delivering", "") delivered = fetch(hass, config, account, data, f"{prefix}_delivered") info = get_count(account, sensor, True) count[sensor] = max(0, info[ATTR_COUNT] - delivered) @@ -442,7 +442,6 @@ def login( def selectfolder(account: Type[imaplib.IMAP4_SSL], folder: str) -> bool: - """Select folder inside the mailbox""" try: account.list() @@ -857,8 +856,13 @@ def get_count( ) found.append(data[0]) - if ATTR_PATTERN in SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"].keys(): - track = SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"][ATTR_PATTERN][0] + if ( + ATTR_PATTERN + in SENSOR_DATA[f"{'_'.join(sensor_type.split('_')[:-1])}_tracking"].keys() + ): + track = SENSOR_DATA[f"{'_'.join(sensor_type.split('_')[:-1])}_tracking"][ + ATTR_PATTERN + ][0] if track is not None and get_tracking_num and count > 0: for sdata in found: @@ -1125,7 +1129,9 @@ def amazon_hub(account: Type[imaplib.IMAP4_SSL], fwds: Optional[str] = None) -> # Get combo number from message body try: - email_msg = quopri.decodestring(str(msg.get_payload(0))) + email_msg = quopri.decodestring( + str(msg.get_payload(0)) + ) # msg.get_payload(0).encode('utf-8') except Exception as err: _LOGGER.debug("Problem decoding email message: %s", str(err)) continue diff --git a/custom_components/mail_and_packages/sensor.py b/custom_components/mail_and_packages/sensor.py index 16ca6999..de290569 100644 --- a/custom_components/mail_and_packages/sensor.py +++ b/custom_components/mail_and_packages/sensor.py @@ -115,7 +115,7 @@ def available(self) -> bool: def extra_state_attributes(self) -> Optional[str]: """Return device specific state attributes.""" attr = {} - tracking = f"{self.type.split('_')[0]}_tracking" + tracking = f"{'_'.join(self.type.split('_')[:-1])}_tracking" data = self.coordinator.data # Catch no data entries @@ -131,6 +131,7 @@ def extra_state_attributes(self) -> Optional[str]: attr[ATTR_IMAGE] = data[ATTR_IMAGE_NAME] elif "_delivering" in self.type and tracking in self.data.keys(): attr[ATTR_TRACKING_NUM] = data[tracking] + # TODO: Add Tracking URL when applicable return attr diff --git a/tests/conftest.py b/tests/conftest.py index 447dfbde..6b7ed541 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1211,13 +1211,13 @@ def mock_imap_auspost_delivered(): @pytest.fixture() -def mock_imap_inpostpl_out_for_delivery(): +def mock_imap_poczta_polska_delivering(): """Mock imap class values.""" with patch( "custom_components.mail_and_packages.helpers.imaplib" - ) as mock_imap_inpostpl_out_for_delivery: + ) as mock_imap_poczta_polska_delivering: mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) - mock_imap_inpostpl_out_for_delivery.IMAP4_SSL.return_value = mock_conn + mock_imap_poczta_polska_delivering.IMAP4_SSL.return_value = mock_conn mock_conn.login.return_value = ( "OK", @@ -1228,7 +1228,7 @@ def mock_imap_inpostpl_out_for_delivery(): [b'(\\HasNoChildren) "/" "INBOX"'], ) mock_conn.search.return_value = ("OK", [b"1"]) - f = open("tests/test_emails/inpostpl_out_for_delivery.eml", "r") + f = open("tests/test_emails/poczta_polska_delivering.eml", "r") email_file = f.read() mock_conn.fetch.return_value = ("OK", [(b"", email_file.encode("utf-8"))]) mock_conn.select.return_value = ("OK", []) @@ -1236,13 +1236,13 @@ def mock_imap_inpostpl_out_for_delivery(): @pytest.fixture() -def mock_imap_inpostpl_delivered(): +def mock_imap_inpost_pl_out_for_delivery(): """Mock imap class values.""" with patch( "custom_components.mail_and_packages.helpers.imaplib" - ) as mock_imap_inpostpl_delivered: + ) as mock_imap_inpost_pl_out_for_delivery: mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) - mock_imap_inpostpl_delivered.IMAP4_SSL.return_value = mock_conn + mock_imap_inpost_pl_out_for_delivery.IMAP4_SSL.return_value = mock_conn mock_conn.login.return_value = ( "OK", @@ -1253,7 +1253,57 @@ def mock_imap_inpostpl_delivered(): [b'(\\HasNoChildren) "/" "INBOX"'], ) mock_conn.search.return_value = ("OK", [b"1"]) - f = open("tests/test_emails/inpostpl_delivered.eml", "r") + f = open("tests/test_emails/inpost_pl_out_for_delivery.eml", "r") + email_file = f.read() + mock_conn.fetch.return_value = ("OK", [(b"", email_file.encode("utf-8"))]) + mock_conn.select.return_value = ("OK", []) + yield mock_conn + + +@pytest.fixture() +def mock_imap_inpost_pl_delivered(): + """Mock imap class values.""" + with patch( + "custom_components.mail_and_packages.helpers.imaplib" + ) as mock_imap_inpost_pl_delivered: + mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) + mock_imap_inpost_pl_delivered.IMAP4_SSL.return_value = mock_conn + + mock_conn.login.return_value = ( + "OK", + [b"user@fake.email authenticated (Success)"], + ) + mock_conn.list.return_value = ( + "OK", + [b'(\\HasNoChildren) "/" "INBOX"'], + ) + mock_conn.search.return_value = ("OK", [b"1"]) + f = open("tests/test_emails/inpost_pl_delivered.eml", "r") + email_file = f.read() + mock_conn.fetch.return_value = ("OK", [(b"", email_file.encode("utf-8"))]) + mock_conn.select.return_value = ("OK", []) + yield mock_conn + + +@pytest.fixture() +def mock_imap_dpd_com_pl_delivering(): + """Mock imap class values.""" + with patch( + "custom_components.mail_and_packages.helpers.imaplib" + ) as mock_imap_dpd_com_pl_delivering: + mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) + mock_imap_dpd_com_pl_delivering.IMAP4_SSL.return_value = mock_conn + + mock_conn.login.return_value = ( + "OK", + [b"user@fake.email authenticated (Success)"], + ) + mock_conn.list.return_value = ( + "OK", + [b'(\\HasNoChildren) "/" "INBOX"'], + ) + mock_conn.search.return_value = ("OK", [b"1"]) + f = open("tests/test_emails/dpd_com_pl_delivering.eml", "r") email_file = f.read() mock_conn.fetch.return_value = ("OK", [(b"", email_file.encode("utf-8"))]) mock_conn.select.return_value = ("OK", []) diff --git a/tests/const.py b/tests/const.py index e9eae482..65ceb1f3 100644 --- a/tests/const.py +++ b/tests/const.py @@ -33,11 +33,17 @@ "auspost_delivered", "auspost_packages", "auspost_delivering", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -88,11 +94,17 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -143,11 +155,17 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -181,12 +199,23 @@ "dhl_delivered", "dhl_delivering", "dhl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", "fedex_delivered", "fedex_delivering", "fedex_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", "hermes_delivered", "hermes_delivering", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", "mail_updated", + "poczta_polska_delivering", + "poczta_polska_packages", "royal_delivered", "royal_delivering", "ups_delivered", @@ -198,11 +227,6 @@ "usps_packages", "zpackages_delivered", "zpackages_transit", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -237,12 +261,23 @@ "dhl_delivered", "dhl_delivering", "dhl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", "fedex_delivered", "fedex_delivering", "fedex_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", "hermes_delivered", "hermes_delivering", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", "mail_updated", + "poczta_polska_delivering", + "poczta_polska_packages", "royal_delivered", "royal_delivering", "ups_delivered", @@ -254,11 +289,6 @@ "usps_packages", "zpackages_delivered", "zpackages_transit", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -277,6 +307,7 @@ "port": 993, "resources": [ "amazon_delivered", + "amazon_exception", "amazon_hub", "amazon_packages", "auspost_delivered", @@ -288,12 +319,23 @@ "dhl_delivered", "dhl_delivering", "dhl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", "fedex_delivered", "fedex_delivering", "fedex_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", "hermes_delivered", "hermes_delivering", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", "mail_updated", + "poczta_polska_delivering", + "poczta_polska_packages", "royal_delivered", "royal_delivering", "ups_delivered", @@ -305,11 +347,6 @@ "usps_packages", "zpackages_delivered", "zpackages_transit", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -353,13 +390,19 @@ "usps_delivering", "usps_mail", "usps_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", "zpackages_delivered", "zpackages_transit", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -403,11 +446,17 @@ "usps_packages", "zpackages_delivered", "zpackages_transit", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -446,11 +495,20 @@ "auspost_delivered": 2, "auspost_delivering": 1, "auspost_packages": 3, - "pocztapolska_delivering": 1, - "pocztapolska_packages": 1, - "inpostpl_delivered": 2, - "inpostpl_delivering": 1, - "inpostpl_packages": 3, + "poczta_polska_delivering": 1, + "poczta_polska_packages": 1, + "inpost_pl_delivered": 2, + "inpost_pl_delivering": 1, + "inpost_pl_packages": 3, + "inpost_pl_tracking": ["520113017830399002575123"], + "dpd_com_pl_delivered": 2, + "dpd_com_pl_delivering": 1, + "dpd_com_pl_packages": 3, + "dpd_com_pl_tracking": ["13490015284111"], + "gls_delivered": 2, + "gls_delivering": 1, + "gls_packages": 3, + "gls_tracking": ["51687952111"], } FAKE_CONFIG_DATA_MISSING_TIMEOUT = { @@ -495,11 +553,17 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -549,11 +613,17 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", @@ -604,11 +674,17 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", + "dpd_com_pl_delivered", + "dpd_com_pl_delivering", + "dpd_com_pl_packages", + "gls_delivered", + "gls_delivering", + "gls_packages", ], "scan_interval": 20, "username": "user@fake.email", diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 4a2ec2a9..8c20255d 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -61,11 +61,11 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "config_3", @@ -110,11 +110,11 @@ "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -223,11 +223,11 @@ async def test_form( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "config_3", @@ -272,11 +272,11 @@ async def test_form( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -422,11 +422,11 @@ async def test_form_connection_error(input_1, step_id_2, hass, mock_imap): "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -464,11 +464,11 @@ async def test_form_connection_error(input_1, step_id_2, hass, mock_imap): "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -557,11 +557,11 @@ async def test_form_invalid_ffmpeg( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -601,11 +601,11 @@ async def test_form_invalid_ffmpeg( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -703,11 +703,11 @@ async def test_form_index_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -747,11 +747,11 @@ async def test_form_index_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -848,11 +848,11 @@ async def test_form_index_error_2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -892,11 +892,11 @@ async def test_form_index_error_2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1021,11 +1021,11 @@ async def test_imap_login_error(mock_imap_login_error, caplog): "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "options_3", @@ -1073,11 +1073,11 @@ async def test_imap_login_error(mock_imap_login_error, caplog): "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1197,11 +1197,11 @@ async def test_options_flow( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "options_3", @@ -1249,11 +1249,11 @@ async def test_options_flow( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1426,11 +1426,11 @@ async def test_options_flow_connection_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -1470,11 +1470,11 @@ async def test_options_flow_connection_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1574,11 +1574,11 @@ async def test_options_flow_invalid_ffmpeg( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -1618,11 +1618,11 @@ async def test_options_flow_invalid_ffmpeg( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1723,11 +1723,11 @@ async def test_options_flow_index_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -1767,11 +1767,11 @@ async def test_options_flow_index_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -1872,11 +1872,11 @@ async def test_options_flow_index_error_2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -1916,11 +1916,11 @@ async def test_options_flow_index_error_2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -2019,11 +2019,11 @@ async def test_options_flow_mailbox_format2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, "imap.test.email", @@ -2066,11 +2066,11 @@ async def test_options_flow_mailbox_format2( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -2177,11 +2177,11 @@ async def test_options_flow_bad( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), @@ -2271,11 +2271,11 @@ async def test_form_amazon_error( "auspost_delivered", "auspost_delivering", "auspost_packages", - "pocztapolska_delivering", - "pocztapolska_packages", - "inpostpl_delivered", - "inpostpl_delivering", - "inpostpl_packages", + "poczta_polska_delivering", + "poczta_polska_packages", + "inpost_pl_delivered", + "inpost_pl_delivering", + "inpost_pl_packages", ], }, ), diff --git a/tests/test_emails/dpd_com_pl_delivering.eml b/tests/test_emails/dpd_com_pl_delivering.eml new file mode 100644 index 00000000..2c2e16e6 --- /dev/null +++ b/tests/test_emails/dpd_com_pl_delivering.eml @@ -0,0 +1,379 @@ +Delivered-To: redacted@gmail.com +Received: by 2002:a02:92c6:0:0:0:0:0 with SMTP id c6csp26473jah; + Wed, 12 Jan 2022 23:09:11 -0800 (PST) +X-Google-Smtp-Source: ABdhPJxp85amMJLKyRyTZ1HiXivViHfnBQJ+286Y3B1phEYe0JE/jm+T5tIAYSg0rPav1f3ASild +X-Received: by 2002:a05:6512:3341:: with SMTP id y1mr2364960lfd.311.1642057751293; + Wed, 12 Jan 2022 23:09:11 -0800 (PST) +ARC-Seal: i=1; a=rsa-sha256; t=1642057751; cv=none; + d=google.com; s=arc-20160816; + b=A/+C63f2OZCcpaoD/ND1h7U7mAMJohm+YSGGgu2BGnpsNAuo/vU5PyNhhXJP+dcNPh + ZzKMWMasxIF8SlN+z4OSvkTmVqVyfwNGRlpcSg41lSUc0BX15A6wqgu9cFJfzEo1uDVU + djJ0Qsxj+rLcsgU0x/Oo5hsM6O3OKqtXWZRlvDnGAgEKWLtvlSEmU85przZMdtD7VDl0 + XnoHkzOpte8u8ypUe/XoTiJX4GBWGPqtGugh1Nie5c4IXIDlY1YFRJd5ickd3G6r1zfg + zBQXkZV+Jx86mw82GmCvDWrVEAs9k6DqxWtpsJfkof8udRZeujCigD5XCBz3x6z+hwk9 + pR/A== +ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; + h=subject:to:from:mime-version:content-transfer-encoding:message-id + :original-message-id:reply-to:date:dkim-signature; + bh=7et06Yb8grI6flUsaVcXiIDgjMTnnCL+V2GSvgGdzjg=; + b=VVTsda3dV+VxGh8hPpHzhWGbCoHSGrFw5FA5dW/kfmBejsZmbjY4H+pp6gnjxQ04sH + ELAOVVepy2XiH4DMCYzlocD42mIYfiI2daML+X5Svr/LN1TDFhSF/by4xl+FctWe9u3b + Gfqv4EL5/c5i/bHBCIHsS5vxgeCTDMgB6fzTVO1U4qc02rBhfN/RnpGwg2xikhRD/rig + wKQGJZTnJXQFtp+ITho5llBfA5AwIW9E+AfRR2Q8DJyUxHK+OLk+zE4kW/4DKbwdFU2L + QSzgrynz3KfrfzLhwansj9M27c20EjPb8j2EkimdYjZQj3E/OhcYrwY5QmgUw5c22gFH + VC9Q== +ARC-Authentication-Results: i=1; mx.google.com; + dkim=pass header.i=@allegromail.pl header.s=smtp header.b=qfe1NVAM; + spf=pass (google.com: domain of powiadomienia@allegromail.pl designates 91.207.14.253 as permitted sender) smtp.mailfrom=powiadomienia@allegromail.pl; + dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=allegromail.pl +Return-Path: +Received: from smtpfarm11.allegro.pl (smtpfarm11.allegro.pl. [91.207.14.253]) + by mx.google.com with ESMTPS id h18si2261684lja.319.2022.01.12.23.09.11 + for + (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); + Wed, 12 Jan 2022 23:09:11 -0800 (PST) +Received-SPF: pass (google.com: domain of powiadomienia@allegromail.pl designates 91.207.14.253 as permitted sender) client-ip=91.207.14.253; +Authentication-Results: mx.google.com; + dkim=pass header.i=@allegromail.pl header.s=smtp header.b=qfe1NVAM; + spf=pass (google.com: domain of powiadomienia@allegromail.pl designates 91.207.14.253 as permitted sender) smtp.mailfrom=powiadomienia@allegromail.pl; + dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=allegromail.pl +DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; + d=allegromail.pl; i=@allegromail.pl; q=dns/txt; s=smtp; + t=1642057751; x=1673593751; + h=reply-to:message-id:content-transfer-encoding: + mime-version:from:to:subject:date; + bh=paezi65dKZpfKqyW40fKmxJLbQjEiSvEtLwNJ+Gp44c=; + b=qfe1NVAMSIFRQMKH2A6xOaDro/I3rHxhk/vF6Fqc6HCqXDASwMnPbTiw + nDcEVRNXmCkyxDDkLk8CMB5053NH3pN8V9fn8ICfqt87b+nLpwzUfeFAL + XDXMVeVm9tLrSFHhwRebAlzreWzO8oQ3kpvN2xUNgTdlCNPAQgPDKRTAV + 8=; +Date: 13 Jan 2022 08:09:09 +0100 +Reply-To: KurierDPD3@dpd.com.pl +Original-Message-ID: <20220113070801.02CA71E15@middle.masterlink.com.pl> +Message-ID: + <20220113080909.c824f64b-1a0b-4bf1-86ac-b0d6c4cfcf27@allegromail.pl> +Content-Type: text/html; charset="UTF-8" +Content-Transfer-Encoding: quoted-printable +MIME-Version: 1.0 +From: "Kurier DPD (via Poczta Allegro)" +To: redacted@gmail.com +Subject: =?utf-8?q?Bezpieczne_dor=C4=99czenie_Twojej_paczki_1000399528451U_-?= + =?utf-8?q?_DPD_Polska?= + +
= +
<= +/td>
=0D + =0D + =0D + =0D + =0D + =0D + =0D +
= +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Drogi Odbiorco,
 
+ Dzi=C5=9B dor=C4=99czamy Twoj=C4=85 paczk=C4=99 1000399528451U= +
+ Mo=C5=BCesz j=C4=85 odebra=C4=87 bezpiecznie - na zewn=C4=85trz lu= +b popro=C5=9B o pozostawienie w portierni/recepcji
+ Uzgodnij z kurierem najbezpieczniejszy dla Ciebie spos=C3=B3b dost= +awy.
+ P=C5=82a=C4=87 bezpiecznie kart=C4=85 za pobranie u kuriera DPD.
+ Poinformuj kuriera je=C5=BCeli przebywasz na kwarantannie.

+ Kurier DPD Polska - 739070409

+
+
P=C5=82atno=C5=9B=C4=87 mo=C5=BCliwa kart=C4=85, BLIKIEM lub got=C3=B3wk=C4=85.
+
 
+ Nie mo=C5=BCesz odebra=C4=87 paczki? Nic straconego! Sprawd=C5=BA = +nowe, ju=C5=BC dost=C4=99pne w ca=C5=82ej Polsce funkcjonalno=C5=9Bci porta= +lu Moja Paczka: https://mojapaczka.dpd.com.pl +
 
+ Portal pozwala na przekierowanie, zmian=C4=99 daty dor=C4=99czenia= +, rezygnacj=C4=99 z paczki i przekierowanie do punktu Pickup.
+
 
Nadawca:
+
ZIELONY PARAPET MARTYN DROZDA WERO= +NIKA KLIMEK SP=C3=93=C5=81KA CYWILNA
+
 
Odbiorca:
+
Adama Pra=C5=BCmowskiego, 7A
+
30399, Krak=C3=B3w, PL
 
+ Numer referencyjny przesy=C5=82ki 1: 367174256 [ucv8ws]
+ Numer referencyjny przesy=C5=82ki 2:
=0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D +
=0D + 3D""=0D +
=0D + 3D""=0D +
=0D + 3D""=0D +
=0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + = +=0D + =0D + =0D + = +=0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D +
 
=0D +=0D + Informujemy, =C5=BCe niniejsze powiadomienie zosta=C5= +=82o wygenerowane automatycznie, prosimy nie odpowiada=C4=87 na t=C4=99=0D + wiadomo=C5=9B=C4=87.=0D +
=0D +
 
=0D + Szczeg=C3=B3=C5=82owe informacje o przesy=C5=82ce: =0D + www.dpd.com.pl
=0D +
Pa=C5=84stwa dane osobowe s=C4=85 przetwarzane przez = +DPD Polska sp. z o.o. z siedzib=C4=85 w Warszawie 02-274 przy ul.=0D + Mineralnej 15, w celu i zakresie wskazanym na stronie inter= +netowej: =0D + www.dpd.com.pl
 
=0D + Dzi=C4=99kujemy za skorzystanie z naszych us=C5=82ug.=0D +
=0D +
Pozdrawiamy,=0D +
=0D + DPD Polska sp. z o.o.
 
=0D +
=0D + 3D""=0D + =0D + 3D""=0D +
=0D + 3D""=0D +
=0D +
=0D + =0D +
=0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D +
=0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D + =0D +
 
=0D +

=0D +=0D + www.dpd.com.pl=0D +

=0D +
=0D +

=0D + =0D +

=0D +
 
 
=0D + DPD Polska sp. z o.o., 0= +2-274 Warszawa, ul. Mineralna 15=0D +
Sp=C3=B3=C5=82ka wpisana do rejestru przedsi=C4=99b= +iorc=C3=B3w w S=C4=85dzie Rejonowym dla m.st.Warszawy=0D +
XIV Wydzia=C5=82 Gospodarczy Krajowego Rejestru S= +=C4=85dowego=0D +
KRS nr 0000028368, NIP:526-020-41-10, kapita=C5=82 = +zak=C5=82adowy: 228.604.000 PLN.
=0D +
 
=0D + Pomy=C5=9Bl o =C5=9Brodo= +wisku! Nie drukuj tej wiadomo=C5=9Bci je=C5=9Bli nie jest to=0D + konieczne.=0D +
 
=0D +
=0D + 3D""=0D +
=0D +
=0D + =0D +=0D += diff --git a/tests/test_emails/gls_delivered.eml b/tests/test_emails/gls_delivered.eml new file mode 100644 index 00000000..f4960a99 --- /dev/null +++ b/tests/test_emails/gls_delivered.eml @@ -0,0 +1,75 @@ +Delivered-To: redacted@gmail.com +Received: by 2002:a59:dd4c:0:b0:271:7674:4f97 with SMTP id s12csp7418849vqs; + Fri, 24 Dec 2021 02:24:22 -0800 (PST) +X-Google-Smtp-Source: ABdhPJz5Ig4uxL9BL+dYNU+hvaV5+AVMiPmKFRatFH33ZOqzPd7zgw6GC+JhX4I1DwNVAmNwB9Bo +X-Received: by 2002:a05:6512:3497:: with SMTP id v23mr4779880lfr.251.1640341461901; + Fri, 24 Dec 2021 02:24:21 -0800 (PST) +ARC-Seal: i=1; a=rsa-sha256; t=1640341461; cv=none; + d=google.com; s=arc-20160816; + b=wgvuQm+xPlnqvw4z8WsZ+r2VcR9NC3496C/mQdqovu7voaHe15R5FpASU2Ajdc85se + GBpmqSbPCJcev3KYKNm0PyeXX59jFEHoxyWzjbjW23JJVelKq0m4gKcV3L0fewXMExzu + Dj1c1y26c1WbgGiNNfz1/PRgGvpUkwh0+07yOGXoPOv0BrHwDS/ydj+Y2H88azotJUMv + lOwhb29k8J21l+hB69KhYUo8lvC/QuHaUCYSk0zvW6E8djCGmyYmqrV/yZ7q6PckBHeX + BZaLlOE7rWI91izdYHeZkogiaho1FOXykQa1qZbkZpxygDuvCDx7jmyyAlAosWsi0yMz + 51qg== +ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; + h=date:message-id:subject:cc:to:from; + bh=h+GyfITiKT9mThGdsFTIQlqBHYxdSdWsTIg6DmHsMws=; + b=rJTaoa2OMxhXFZ3qiRR/jpMCy8JAI6V0FBTNPjLKgvNxYspOkq355Vc11ez/xJ7itN + nqJKEn7vOH2/XWw3ATYvrEQvnZPvDLcdNgD1o5ZbWnM53VXQMLjxVeITbQyMnVLVQvSn + y+PPJTnAcRdgk9mf4GbFiTVWfpbLE443/RXclV4ZcNFMeNwDCc9V+Jpt/3txicBn+MrN + RitiURmAR0ML/CrZaLIUQ3BaNlIBDoWQz9ezuUaJUo04u8xWsVBSv+bwwOJlEIVZeKfS + Yf/Vtfwln9ziuY5IOGnb9NpwF6YOZgE/ZExqF2vaE4CypLWhYAHHxfk1/peahrjIu30Y + m6kw== +ARC-Authentication-Results: i=1; mx.google.com; + spf=pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) smtp.mailfrom=noreply@gls-group.eu; + dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gls-group.eu +Return-Path: +Received: from glsmail02.gls-group.eu (glsmail02.gls-group.eu. [193.106.225.236]) + by mx.google.com with ESMTPS id l8si6678000ljg.487.2021.12.24.02.24.21 + for + (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); + Fri, 24 Dec 2021 02:24:21 -0800 (PST) +Received-SPF: pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) client-ip=193.106.225.236; +Authentication-Results: mx.google.com; + spf=pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) smtp.mailfrom=noreply@gls-group.eu; + dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gls-group.eu +Received: from apl1.portal1.gls-unique.com (glsmail-vip [193.106.225.20]) + by glsmail02.gls-group.eu (Postfix) with ESMTP id 19699803EFE7 + for ; Fri, 24 Dec 2021 11:24:21 +0100 (CET) +Received: by apl1.portal1.gls-unique.com (Postfix, from userid 1000) + id 1A49C18000A7; Fri, 24 Dec 2021 11:24:21 +0100 (CET) +From: GLS +To: redacted@gmail.com +CC: +Subject: =?ISO-8859-1?Q?Twoja=20paczka=20od=20Mailboxde.com=20GmbH=20CLIPA:=20informacja=20o=20dostawie?= +Content-Type: text/html; charset=UTF-8 +Message-Id: <20211224102421.1A49C18000A7@apl1.portal1.gls-unique.com> +Date: Fri, 24 Dec 2021 11:24:21 +0100 (CET) + + + +

GLS FlexDeliveryService

Szanowny Odbiorco,
+
+informujemy, że Twoja paczka o numerze 90346692444 nadana przez Sender Name, została dzisiaj dostarczona o godzinie 11:18 na następujący adres:
+
+John Doe A redacted@gmail.com
+Address Line 7
+12-345 City
+
+Dziękujemy za skorzystanie z usług GLS!
+
+Pozdrawiamy,
+Zespół GLS
+
+Infolinia GLS:
+
+46 814 82 20 (koszt wg stawek operatora osoby dzwoniącej).
+Godziny pracy: pon.-pt. w godzinach 7.00 - 19.00, w sob. w godzinach 7.00 - 15.00.
+
+Odwiedź nas na www.gls-group.eu
+
+Wiadomość wygenerowana automatycznie, prosimy na nią nie odpowiadać.
+
+
+ diff --git a/tests/test_emails/gls_delivering.eml b/tests/test_emails/gls_delivering.eml new file mode 100644 index 00000000..3c1873ab --- /dev/null +++ b/tests/test_emails/gls_delivering.eml @@ -0,0 +1,83 @@ +Delivered-To: redacted@email.com +Received: by 2002:a59:dd4c:0:b0:271:7674:4f97 with SMTP id s12csp6228910vqs; + Wed, 22 Dec 2021 15:33:25 -0800 (PST) +X-Google-Smtp-Source: ABdhPJwl1sMjV9+o4x8RfnBQCcpCFjO3Sh2cRSw74UIz2CMgcwcQu8tIhYEsJUwMzNqCh72aHoPj +X-Received: by 2002:a1c:f609:: with SMTP id w9mr34829wmc.99.1640216005734; + Wed, 22 Dec 2021 15:33:25 -0800 (PST) +ARC-Seal: i=1; a=rsa-sha256; t=1640216005; cv=none; + d=google.com; s=arc-20160816; + b=zdEriAwtdMCGH8QHusQ010U4oe6rH1U6hp9EhG5G/+7mHom7iJs1q0MDC+quIilGKi + k8QsMx0ZeiZhH+8HwQ1QaDNlD8tLmrslWz59QeJuTXf15Ke7DN9IE171K47fiRglyYmL + t87moR7q8MWGQjQHAvzggDZ55PONWGyuI3LS/EKIm/F4QT4wpGqCMgjn03JkQAPZ/LKu + lzj/tC+OGZ7WYMsQA+kq+wYcjHr4JetNFWpsEGx2vMXTiSAxXKKVyGn4ipH9q1mywp+V + Iv7g2McAgGrxcdrEKudoDxlaAYgwBSwA4TkuExcIIlSjrNZmJ8bfr2UVMqQJ9ydSPCEr + 3mbQ== +ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; + h=date:message-id:subject:cc:to:from; + bh=HXz5SQODCpjGMSO4I6NtjsLeuwbAaeONx+w+ZkYs+yg=; + b=sXCuyp0MNrrf5FVY8sxufnObt6oy6qYpMpo/3k8huurSQy9j74/OTcVWWt1oESTXRG + IA7G/d1jgU8MQysO9VRG5PXJP373NajuW1i8CzKDB0lY0ExBuhgSOzumk+kM4rnPVrlW + 9dJ0dUcf0yjGApsa8/V2Km1F8/yPUC4860vSGmJR0xJyvMMLwMMt46627A7kan3rulXw + KlX57X+ilT0od4iy6f4v6fbt3gn/ePCELvqVhgOjvdvNSec1FvWPJF6p9psoNI/R2i15 + jhyC6W6d0L+z4gG/zJAnOAt0/ARv7rtp+uav5OdeYhbR8YFR+9fT1NPswFk/LdPPINdT + HCoQ== +ARC-Authentication-Results: i=1; mx.google.com; + spf=pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) smtp.mailfrom=noreply@gls-group.eu; + dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gls-group.eu +Return-Path: +Received: from glsmail02.gls-group.eu (glsmail02.gls-group.eu. [193.106.225.236]) + by mx.google.com with ESMTPS id g2si1638247wrq.775.2021.12.22.15.33.25 + for + (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); + Wed, 22 Dec 2021 15:33:25 -0800 (PST) +Received-SPF: pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) client-ip=193.106.225.236; +Authentication-Results: mx.google.com; + spf=pass (google.com: domain of noreply@gls-group.eu designates 193.106.225.236 as permitted sender) smtp.mailfrom=noreply@gls-group.eu; + dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gls-group.eu +Received: from apl7.portal1.gls-unique.com (glsmail-vip [193.106.225.20]) + by glsmail02.gls-group.eu (Postfix) with ESMTP id 3607C803F264 + for ; Thu, 23 Dec 2021 00:33:25 +0100 (CET) +Received: by apl7.portal1.gls-unique.com (Postfix, from userid 1000) + id 36D151800088; Thu, 23 Dec 2021 00:33:25 +0100 (CET) +From: GLS +To: redacted@email.com +CC: +Subject: =?ISO-8859-1?Q?Kurier=20GLS=20-=20wybierz=20opcje=20dostawy=20-=20paczka=20w=20drodze?= +Content-Type: text/html; charset=UTF-8 +Message-Id: <20211222233325.36D151800088@apl7.portal1.gls-unique.com> +Date: Thu, 23 Dec 2021 00:33:25 +0100 (CET) + + + +

GLS FlexDeliveryService

Szanowny Odbiorco,
+
+informujemy, że paczka o numerze: 90346692444 (Nr referencyjny: 23221984) nadana przez Mailboxde.com GmbH CLIPA została przekazana kurierowi GLS.
+
+Przewidywana data doręczenia:2021-12-24.w godzinach: 11:00 - 16:00.
+
+Nie będzie Ciebie w miejscu dostawy w podanym terminie? Skorzystaj z jednej z wielu opcji przekierowań paczek np. odbierz wygodnie i bezpiecznie swoje paczki z punktów Szybka Paczka / ParcelShop na terenie całego kraju!
+
+Kliknij w poniższy link i przekieruj swoją paczkę np. do wybranego przez Ciebie punktu Szybka Paczka / ParcelShop.
+
+Zmieniam za pomoca przegladarki www
+
+Jeśli wcześniej złożona została dyspozycja zmiany dostawy, nie ma potrzeby ponownego jej dokonywania.
+
+ Aktualnie wybrany adres doręczenia: John Doe A redacted@email.com, ul. Street Name 7, 12-345 City.
+
+Odbierając paczkę pobraniową od kuriera skorzystaj z bezdotykowej usługi płatności BLIKIEM lub zapłać gotówką.
+
+Pozdrawiamy,
+Zespół GLS
+
+Infolinia GLS:
+
+46 814 82 20 (koszt wg stawek operatora osoby dzwoniącej).
+Godziny pracy: pon.-pt. w godzinach 7.00 - 19.00, w sob. w godzinach 7.00 - 15.00.
+
+Odwiedź nas na www.gls-group.eu
+
+Wiadomość wygenerowana automatycznie, prosimy na nią nie odpowiadać.
+
+
+ diff --git a/tests/test_emails/inpostpl_delivered.eml b/tests/test_emails/inpost_pl_delivered.eml similarity index 99% rename from tests/test_emails/inpostpl_delivered.eml rename to tests/test_emails/inpost_pl_delivered.eml index 50138412..27db1436 100644 --- a/tests/test_emails/inpostpl_delivered.eml +++ b/tests/test_emails/inpost_pl_delivered.eml @@ -1,3 +1,5 @@ +From: "Kurier InPost (via Poczta Allegro)" +Subject: Twoja paczka jest już prawie u Ciebie ------=_Part_18559691_431614451.1641551203581 Content-Type: text/html;charset=UTF-8 @@ -652,7 +654,7 @@ com/c/InpostPl-twoj-inpost" target=3D"_blank"> diff --git a/tests/test_emails/inpostpl_out_for_delivery.eml b/tests/test_emails/inpost_pl_out_for_delivery.eml similarity index 100% rename from tests/test_emails/inpostpl_out_for_delivery.eml rename to tests/test_emails/inpost_pl_out_for_delivery.eml diff --git a/tests/test_emails/pocztapolska_out_for_delivery.eml b/tests/test_emails/poczta_polska_delivering.eml similarity index 69% rename from tests/test_emails/pocztapolska_out_for_delivery.eml rename to tests/test_emails/poczta_polska_delivering.eml index 71c201cf..21058c04 100644 --- a/tests/test_emails/pocztapolska_out_for_delivery.eml +++ b/tests/test_emails/poczta_polska_delivering.eml @@ -1,22 +1,28 @@ +From: informacja@poczta-polska.pl +Subject: Poczta Polska S.A. eINFO -Dzień dobry, +------=_Part_100864109_559649553.1606574683953 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable -Dziś doręczymy Twoją przesyłkę 00111222333444555666. +Dzień dobry, + +Dziś doręczymy Twoją przesyłkę 00111222333444555666. Uzgodnij bezpieczną dostawę. Kurier tel. 555666777. Odbierz za pomoca kodu odbioru: 433566 -Przesyłki (z zastrzeżeniem przesyłek z dokumentami zwrotnymi) możesz odebrać bez pokwitowania. Okaż kurierowi z bezpiecznej odległości dokument tożsamości np. dowód osobisty, paszport, prawo jazdy. Kurier spisze 4 ostatnie cyfry numeru dokumentu. +Przesyłki (z zastrzeżeniem przesyłek z dokumentami zwrotnymi) możesz odebrać bez pokwitowania. Okaż kurierowi z bezpiecznej odległości dokument tożsamości np. dowód osobisty, paszport, prawo jazdy. Kurier spisze 4 ostatnie cyfry numeru dokumentu. -W przypadku przesyłek pobraniowych polecamy płatność kartą. +W przypadku przesyłek pobraniowych polecamy płatność kartą. Szczegółowe informacje o przesyłce: http://emonitoring.poczta-polska.pl/?numer=00111222333444555666 Polecamy zakupy on-line i bezpieczną formę dostawy pod adres realizowaną przez Pocztę Polską. Szczegółowe informacje dotyczące specjalnych procedur: -www.poczta-polska.pl; www.pocztex.pl; www.facebook.com/pocztapolska. +www.poczta-polska.pl; www.pocztex.pl; www.facebook.com/poczta_polska. Niniejsze powiadomienie zostało wygenerowane automatycznie. diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 8faa70d2..2685f206 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -418,7 +418,7 @@ async def test_image_filename_oserr( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 assert "Problem accessing file:" in caplog.text @@ -446,7 +446,7 @@ async def test_image_getctime_oserr( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 assert "Problem accessing file:" in caplog.text @@ -800,7 +800,7 @@ async def test_amazon_shipped_order_it_count(hass, mock_imap_amazon_shipped_it): with patch("datetime.date") as mock_date: mock_date.today.return_value = date(2021, 12, 1) result = get_items(mock_imap_amazon_shipped_it, "count") - assert result == 1 + assert result == 0 async def test_amazon_search(hass, mock_imap_no_email): @@ -812,7 +812,7 @@ async def test_amazon_search_results(hass, mock_imap_amazon_shipped): result = amazon_search( mock_imap_amazon_shipped, "test/path", hass, "testfilename.jpg" ) - assert result == 12 + assert result == 21 async def test_amazon_search_delivered( @@ -821,7 +821,7 @@ async def test_amazon_search_delivered( result = amazon_search( mock_imap_amazon_delivered, "test/path", hass, "testfilename.jpg" ) - assert result == 12 + assert result == 21 assert mock_download_img.called @@ -831,7 +831,7 @@ async def test_amazon_search_delivered_it( result = amazon_search( mock_imap_amazon_delivered_it, "test/path", hass, "testfilename.jpg" ) - assert result == 12 + assert result == 21 async def test_amazon_hub(hass, mock_imap_amazon_the_hub): @@ -1049,13 +1049,14 @@ async def test_amazon_exception(hass, mock_imap_amazon_exception, caplog): "123-1234567-1234567", "123-1234567-1234567", "123-1234567-1234567", + "123-1234567-1234567", ] - assert result["count"] == 6 + assert result["count"] == 7 result = amazon_exception(mock_imap_amazon_exception, ["testemail@fakedomain.com"]) - assert result["count"] == 7 + assert result["count"] == 8 assert ( - "Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', 'testemail@fakedomain.com']" + "Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', 'amazon.pl', 'testemail@fakedomain.com']" in caplog.text ) @@ -1063,7 +1064,7 @@ async def test_amazon_exception(hass, mock_imap_amazon_exception, caplog): async def test_hash_file(): """Test file hashing function.""" result = hash_file("tests/test_emails/amazon_delivered.eml") - assert result == "7f9d94e97bb4fc870d2d2b3aeae0c428ebed31dc" + assert result == "0e2c7e290472fffc0cb1c6b6b860b4bd7f386f7c" async def test_fedex_out_for_delivery(hass, mock_imap_fedex_out_for_delivery): diff --git a/tests/test_init.py b/tests/test_init.py index 954eeb50..79dfeefb 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -28,13 +28,13 @@ async def test_unload_entry(hass, mock_update, mock_copy_overlays): assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 assert await hass.config_entries.async_unload(entries[0].entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 assert len(hass.states.async_entity_ids(DOMAIN)) == 0 assert await hass.config_entries.async_remove(entries[0].entry_id) @@ -65,7 +65,7 @@ async def test_setup_entry( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 @@ -91,7 +91,7 @@ async def test_no_path_no_sec( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 31 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 @@ -120,7 +120,7 @@ async def test_missing_imap_timeout( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 31 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 42 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 @@ -149,7 +149,7 @@ async def test_amazon_fwds_string( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 31 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 42 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 @@ -177,6 +177,6 @@ async def test_custom_img( assert await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 32 + assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 43 entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 52511315..51799f84 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -108,23 +108,47 @@ async def test_sensor(hass, mock_update): assert state assert state.state == "3" - state = hass.states.get("sensor.mail_pocztapolska_delivering") + state = hass.states.get("sensor.mail_poczta_polska_delivering") assert state assert state.state == "1" - state = hass.states.get("sensor.mail_pocztapolska_packages") + state = hass.states.get("sensor.mail_poczta_polska_packages") assert state assert state.state == "1" - state = hass.states.get("sensor.mail_inpostpl_delivered") + state = hass.states.get("sensor.mail_inpost_pl_delivered") assert state assert state.state == "2" - state = hass.states.get("sensor.mail_inpostpl_delivering") + state = hass.states.get("sensor.mail_inpost_pl_delivering") assert state assert state.state == "1" - state = hass.states.get("sensor.mail_inpostpl_packages") + state = hass.states.get("sensor.mail_inpost_pl_packages") + assert state + assert state.state == "3" + + state = hass.states.get("sensor.mail_dpd_com_pl_delivered") + assert state + assert state.state == "2" + + state = hass.states.get("sensor.mail_dpd_com_pl_delivering") + assert state + assert state.state == "1" + + state = hass.states.get("sensor.mail_dpd_com_pl_packages") + assert state + assert state.state == "3" + + state = hass.states.get("sensor.mail_gls_delivered") + assert state + assert state.state == "2" + + state = hass.states.get("sensor.mail_gls_delivering") + assert state + assert state.state == "1" + + state = hass.states.get("sensor.mail_gls_packages") assert state assert state.state == "3"