Skip to content

Commit

Permalink
fix: update fedex subject search (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Dec 1, 2021
2 parents d72dfb9 + 2725973 commit b8ee40c
Show file tree
Hide file tree
Showing 4 changed files with 859 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom_components/mail_and_packages/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"Delivery scheduled for today",
"Your package is scheduled for delivery today",
"Your package is now out for delivery",
"out for delivery today",
],
},
"fedex_packages": {},
Expand Down
24 changes: 24 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,30 @@ def mock_imap_fedex_out_for_delivery():
mock_conn.select.return_value = ("OK", [])
yield mock_conn

@pytest.fixture()
def mock_imap_fedex_out_for_delivery_2():
"""Mock imap class values."""
with patch(
"custom_components.mail_and_packages.helpers.imaplib"
) as mock_imap_dhl_out_for_delivery:
mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL)
mock_imap_dhl_out_for_delivery.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/fedex_out_for_delivery_2.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_out_for_delivery():
Expand Down
Loading

0 comments on commit b8ee40c

Please sign in to comment.