-
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(shipper): add evri carrier (#720)
* feat(shipper): add evri carrier * linting
- Loading branch information
Showing
6 changed files
with
552 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,6 +388,17 @@ | |
}, | ||
"auspost_packages": {}, | ||
"auspost_tracking": {"pattern": ["\\d{7,10,12}|[A-Za-z]{2}[0-9]{9}AU "]}, | ||
# Evri | ||
"evri_delivered": { | ||
"email": ["[email protected]"], | ||
"subject": ["successfully delivered"], | ||
}, | ||
"evri_delivering": { | ||
"email": ["[email protected]"], | ||
"subject": ["is now with your local Evri courier for delivery"], | ||
}, | ||
"evri_packages": {}, | ||
"evri_tracking": {"pattern": ["H[0-9A-Z]{15}"]}, | ||
} | ||
|
||
# Sensor definitions | ||
|
@@ -670,6 +681,25 @@ | |
icon="mdi:package-variant-closed", | ||
key="gls_packages", | ||
), | ||
# Evri | ||
"evri_delivered": SensorEntityDescription( | ||
name="Mail Evri Delivered", | ||
native_unit_of_measurement="package(s)", | ||
icon="mdi:package-variant-closed", | ||
key="evri_delivered", | ||
), | ||
"evri_delivering": SensorEntityDescription( | ||
name="Mail Evri Delivering", | ||
native_unit_of_measurement="package(s)", | ||
icon="mdi:truck-delivery", | ||
key="evri_delivering", | ||
), | ||
"evri_packages": SensorEntityDescription( | ||
name="Mail Evri Packages", | ||
native_unit_of_measurement="package(s)", | ||
icon="mdi:package-variant-closed", | ||
key="evri_packages", | ||
), | ||
### | ||
# !!! Insert new sensors above these two !!! | ||
### | ||
|
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 |
---|---|---|
|
@@ -936,6 +936,7 @@ def mock_image_excpetion(): | |
mock_image_excpetion.open.side_effect = Exception("SystemError") | ||
yield mock_image_excpetion | ||
|
||
|
||
@pytest.fixture | ||
def mock_image_save_excpetion(): | ||
"""Fixture to mock Image.""" | ||
|
@@ -946,12 +947,15 @@ def mock_image_save_excpetion(): | |
mock_image_save_excpetion.Image.save.side_effect = Exception("ValueError") | ||
yield mock_image_save_excpetion | ||
|
||
|
||
@pytest.fixture | ||
def mock_resizeimage(): | ||
"""Fixture to mock splitext.""" | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.Image" | ||
) as mock_resizeimage, patch("custom_components.mail_and_packages.helpers.ImageOps"): | ||
) as mock_resizeimage, patch( | ||
"custom_components.mail_and_packages.helpers.ImageOps" | ||
): | ||
|
||
yield mock_resizeimage | ||
|
||
|
@@ -1034,6 +1038,32 @@ def mock_imap_hermes_out_for_delivery(): | |
yield mock_conn | ||
|
||
|
||
@pytest.fixture() | ||
def mock_imap_evri_out_for_delivery(): | ||
"""Mock imap class values.""" | ||
with patch( | ||
"custom_components.mail_and_packages.helpers.imaplib" | ||
) as mock_imap_evri_out_for_delivery: | ||
mock_conn = mock.Mock(spec=imaplib.IMAP4_SSL) | ||
mock_imap_evri_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"]) | ||
mock_conn.uid.return_value = ("OK", [b"1"]) | ||
f = open("tests/test_emails/evri_out_for_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_royal_out_for_delivery(): | ||
"""Mock imap class values.""" | ||
|
Oops, something went wrong.