-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,305 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,11 @@ | |
AMAZON_HUB_EMAIL = "[email protected]" | ||
AMAZON_HUB_SUBJECT = "(You have a package to pick up)(.*)- (\\d{6})" | ||
AMAZON_TIME_PATTERN = "will arrive:,estimated delivery date is:,guaranteed delivery date is:,Arriving:,Arriver:" | ||
AMAZON_EXCEPTION_SUBJECT = "Delivery update:" | ||
AMAZON_EXCEPTION_BODY = "running late" | ||
AMAZON_EXCEPTION = "amazon_exception" | ||
AMAZON_EXCEPTION_ORDER = "amazon_exception_order" | ||
AMAZON_PATTERN = "[0-9]{3}-[0-9]{7}-[0-9]{7}" | ||
|
||
# Sensor Data | ||
SENSOR_DATA = { | ||
|
@@ -221,6 +226,7 @@ | |
"package(s)", | ||
"mdi:package-variant-closed", | ||
], | ||
"amazon_exception": ["Mail Amazon Exception", "package(s)", "mdi:archive-alert"], | ||
"amazon_hub": ["Mail Amazon Hub Packages", "package(s)", "mdi:amazon"], | ||
"capost_delivered": [ | ||
"Mail Canada Post Delivered", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -978,3 +978,28 @@ def mock_copytree(): | |
with patch("custom_components.mail_and_packages.helpers.copytree") as mock_copytree: | ||
mock_copytree.return_value = True | ||
yield mock_copytree | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap_amazon_exception(): | ||
""" Mock imap class values. """ | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.imaplib" | ||
) as mock_imap_amazon_exception: | ||
mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) | ||
mock_imap_amazon_exception.IMAP4_SSL.return_value = mock_conn | ||
|
||
mock_conn.login.return_value = ( | ||
"OK", | ||
[b"[email protected] authenticated (Success)"], | ||
) | ||
mock_conn.list.return_value = ( | ||
"OK", | ||
[b'(\\HasNoChildren) "/" "INBOX"'], | ||
) | ||
mock_conn.search.return_value = ("OK", [b"1"]) | ||
f = open("tests/test_emails/amazon_exception.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.