-
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: add Amazon OTP password sensor (#1037)
- Loading branch information
Showing
5 changed files
with
718 additions
and
0 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 |
---|---|---|
|
@@ -1708,3 +1708,27 @@ def mock_update_amazon_image(): | |
# value = mock.Mock() | ||
mock_update.return_value = FAKE_UPDATE_DATA_BIN | ||
yield mock_update | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap_amazon_otp(): | ||
"""Mock imap class values.""" | ||
with patch("custom_components.mail_and_packages.helpers.imaplib") as mock_imap: | ||
mock_conn = mock.Mock(autospec=imaplib.IMAP4_SSL) | ||
mock_imap.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/amazon_otp.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 |
Oops, something went wrong.