diff --git a/custom_components/mail_and_packages/const.py b/custom_components/mail_and_packages/const.py index ff84ae93..e751ba4e 100644 --- a/custom_components/mail_and_packages/const.py +++ b/custom_components/mail_and_packages/const.py @@ -147,6 +147,7 @@ "Delivery scheduled for today", "Your package is scheduled for delivery today", "Your package is now out for delivery", + "out for delivery today", ], }, "fedex_packages": {}, diff --git a/tests/conftest.py b/tests/conftest.py index aa450a36..94ee2045 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -404,6 +404,30 @@ def mock_imap_fedex_out_for_delivery(): mock_conn.select.return_value = ("OK", []) yield mock_conn +@pytest.fixture() +def mock_imap_fedex_out_for_delivery_2(): + """Mock imap class values.""" + with patch( + "custom_components.mail_and_packages.helpers.imaplib" + ) as mock_imap_dhl_out_for_delivery: + mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) + mock_imap_dhl_out_for_delivery.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/fedex_out_for_delivery_2.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_usps_out_for_delivery(): diff --git a/tests/test_emails/fedex_out_for_delivery_2.eml b/tests/test_emails/fedex_out_for_delivery_2.eml new file mode 100644 index 00000000..22415bf7 --- /dev/null +++ b/tests/test_emails/fedex_out_for_delivery_2.eml @@ -0,0 +1,826 @@ +Date: Wed, 01 Dec 2021 04:07:34 -0600 +From: FedEx Delivery Manager +Reply-To: trackingmail@fedex.com +To: email@gmail.com +Subject: FedEx Shipment 286548999999: Your packages are now out for delivery + today +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_6974041_1805770234.1638353157452" +------=_Part_6974041_1805770234.1638353157452 +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + + + + + +FedEx + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + +
+ +
+ + + + + + +
+spacer.gif +Hi, My Name. Your packages from Express Water Inc. are now out for delivery today. +spacer.gif +
+
+ +
+ + + + +
+ +
+ + + + + + +
+ + + + + + +
+ + + + + + + +
SCHEDULED DELIVERY
Pending
+
+
+ +
+ + + + +
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
TRACKING IDSTATUS
+ +
+286548999999 + + + + + + +
+ + + + + + + + + +
On FedEx vehicle for delivery
PALMETTO, + FL
+
+
+ +
286548999979 + + + + + + +
+ + + + + + + + + +
On FedEx vehicle for delivery
PALMETTO, + FL
+
+
+ +
+
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
MASTER TRACKING NUMBER + +286548999989 +
+ +
FROM + +Express Water Inc. +
12730 Raymer St +
Unit 1 +
North Hollywood, CA, US, 91605
+ +
TO + +My Name +
My Name +
99999 STREET RD +
CITY, STATE, ZIP
+ +
PURCHASE ORDER NUMBER + +8119
+ +
REFERENCE + +113-2208711-1430629
+ +
SHIP DATE + +Wed 11/24/2021 12:00 AM
+ +
PACKAGING TYPE + +Package
+ +
ORIGIN + +North Hollywood, CA, US, 91605
+ +
DESTINATION + +RIVERVIEW, FL, US, 33569
+ +
STANDARD TRANSIT + +Wed, 12/01/2021
+ +
NUMBER OF PIECES + +2
+ +
TOTAL SHIPMENT WEIGHT + +24.00 LB
+ +
SERVICE TYPE + +FedEx Home Delivery
+ +
+
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ + + + + +
+ + + + +
+FedEx +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
Ask us to hold a package
+ +
Simplify your holiday errands. Pick up holiday packages at convenient FedEx Office®, Walgreens, Dollar General, and other locations—it’s easy and it’s free.
+ +
+ + + + + + + + + + +
+ +
+ +GET THE DETAILS + +
+ +
+
+
+ +
+
+
+ + + + +
+ +
+ + + + +
+ +
+ + + + + + +
+ + + + + + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + + + +
+ +
FOLLOW FEDEX
+ +
+ + + + +
+ +
+ + + + + + + + + + +
+ +Facebook + + + +Twitter + + + +Instagram + + + +LinkedIn + + + +Pinterest + + + +YouTube + + + +Google Plus + +
+
+ + + + + + + +
+ +
+email +   + + Please do not respond to this message. This email was sent from an unattended mailbox. This report was generated at approximately 4:05 AM CST 12/01/2021.
+
All weights are estimated. +
+
To track the latest status of your shipment, click on the tracking number above. +
+
Standard transit is the date and time the package is scheduled to be delivered by, based on the selected service, destination and ship date. Limitations and exceptions may apply. Please see the FedEx Service Guide for terms and conditions of service, including the FedEx Money-Back Guarantee, or contact your FedEx Customer Support representative. +
+
© 2021 Federal Express Corporation. The content of this message is protected by copyright and trademark laws under U.S. and international law. Review our privacy policy. Find information on fraud and security. All rights reserved. +
+
Thank you for your business. +
+
You can unsubscribe or update your email profile at any time.
+
+ +
+
+ + + +------=_Part_6974041_1805770234.1638353157452-- + + diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 5938ef2a..f1c8102d 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1058,6 +1058,14 @@ async def test_fedex_out_for_delivery(hass, mock_imap_fedex_out_for_delivery): assert result["tracking"] == ["61290912345678912345"] +async def test_fedex_out_for_delivery_2(hass, mock_imap_fedex_out_for_delivery_2): + result = get_count( + mock_imap_fedex_out_for_delivery_2, "fedex_delivering", True, "./", hass + ) + assert result["count"] == 1 + assert result["tracking"] == ["286548999999"] + + async def test_get_mails_email_search_none( mock_imap_usps_informed_digest_no_mail, mock_copyoverlays,