-
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.
feat: parse new USPS informed delivery digest emails (#739)
* feat: parse new USPS informed delivery digest emails * linting
- Loading branch information
Showing
6 changed files
with
11,188 additions
and
25 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
Pillow>=9.0 | ||
Pillow>=9.0 | ||
beautifulsoup4 |
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 |
---|---|---|
|
@@ -265,6 +265,32 @@ def mock_imap_usps_informed_digest(): | |
yield mock_conn | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap_usps_new_informed_digest(): | ||
"""Mock imap class values.""" | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.imaplib" | ||
) as mock_imap_usps_new_informed_digest: | ||
mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) | ||
mock_imap_usps_new_informed_digest.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"]) | ||
mock_conn.uid.return_value = ("OK", [b"1"]) | ||
f = open("tests/test_emails/new_informed_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_usps_informed_digest_missing(): | ||
"""Mock imap class values.""" | ||
|
Oops, something went wrong.