-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support Canda Post mail count (#1068)
- Loading branch information
Showing
6 changed files
with
1,866 additions
and
3 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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
from tests.const import ( | ||
FAKE_CONFIG_DATA, | ||
FAKE_CONFIG_DATA_AMAZON_FWD_STRING, | ||
FAKE_CONFIG_DATA_CAPOST, | ||
FAKE_CONFIG_DATA_CUSTOM_IMG, | ||
FAKE_CONFIG_DATA_EXTERNAL, | ||
FAKE_CONFIG_DATA_MISSING_TIMEOUT, | ||
|
@@ -164,6 +165,22 @@ async def integration_fixture_7(hass): | |
return entry | ||
|
||
|
||
@pytest.fixture(name="integration_capost") | ||
async def integration_fixture_8(hass): | ||
"""Set up the mail_and_packages integration.""" | ||
entry = MockConfigEntry( | ||
domain=DOMAIN, | ||
title="imap.test.email", | ||
data=FAKE_CONFIG_DATA_CAPOST, | ||
version=CONFIG_VER, | ||
) | ||
entry.add_to_hass(hass) | ||
await hass.config_entries.async_setup(entry.entry_id) | ||
await hass.async_block_till_done() | ||
|
||
return entry | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap(): | ||
"""Mock imap class values.""" | ||
|
@@ -1740,3 +1757,30 @@ def mock_imap_amazon_otp(): | |
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_capost_mail(): | ||
"""Mock imap class values.""" | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.imaplib" | ||
) as mock_imap_capost_mail: | ||
mock_conn = mock.Mock(autospec=imaplib.IMAP4_SSL) | ||
mock_imap_capost_mail.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/capost_mail.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -924,3 +924,28 @@ | |
"username": "[email protected]", | ||
"verify_ssl": False, | ||
} | ||
|
||
FAKE_CONFIG_DATA_CAPOST = { | ||
"allow_external": False, | ||
"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": [ | ||
"zpackages_delivered", | ||
"zpackages_transit", | ||
"capost_mail", | ||
], | ||
"scan_interval": 20, | ||
"storage": ".storage/mail_and_packages/images/", | ||
"username": "[email protected]", | ||
"verify_ssl": False, | ||
} |
Oops, something went wrong.