forked from moralmunky/Home-Assistant-Mail-And-Packages
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix small bug when enabling usps mail delivered sensor (moralmun…
- Loading branch information
Showing
6 changed files
with
1,312 additions
and
2 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 |
---|---|---|
|
@@ -503,6 +503,32 @@ def mock_imap_usps_informed_digest_no_mail(): | |
yield mock_conn | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap_usps_mail_delivered(): | ||
"""Mock imap class values.""" | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.imaplib" | ||
) as mock_imap_usps_mail_delivered: | ||
mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) | ||
mock_imap_usps_mail_delivered.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/usps_mail_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_ups_out_for_delivery(): | ||
"""Mock imap class values.""" | ||
|
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 |
---|---|---|
|
@@ -898,3 +898,26 @@ | |
"username": "[email protected]", | ||
"verify_ssl": False, | ||
} | ||
|
||
FAKE_CONFIG_DATA_USPS_DELIVERED = { | ||
"allow_external": False, | ||
"amazon_days": 3, | ||
"amazon_domain": "amazon.com", | ||
"amazon_fwds": "[email protected], [email protected]", | ||
"custom_img": False, | ||
"folder": '"INBOX"', | ||
"generate_mp4": False, | ||
"gif_duration": 5, | ||
"host": "imap.test.email", | ||
"image_name": "mail_today.gif", | ||
"image_path": "custom_components/mail_and_packages/images/", | ||
"image_security": True, | ||
"imap_security": "SSL", | ||
"imap_timeout": 30, | ||
"password": "suchfakemuchpassword", | ||
"port": 993, | ||
"resources": ["usps_mail_delivered"], | ||
"scan_interval": 20, | ||
"username": "[email protected]", | ||
"verify_ssl": False, | ||
} |
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.