Skip to content

Commit

Permalink
fix(shipper): add amazon.com.au and update auspost_delivering (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored and github-actions[bot] committed Feb 7, 2022
2 parents 78a3afb + cf06ca8 commit 565b17a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements_test.txt
pip install --use-deprecated legacy-resolver -r requirements_test.txt
sudo apt-get update
sudo apt-get -y install language-pack-it
- name: Generate coverage report
Expand Down
6 changes: 4 additions & 2 deletions custom_components/mail_and_packages/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
DEFAULT_AMAZON_DAYS = 3

# Amazon
AMAZON_DOMAINS = "amazon.com,amazon.ca,amazon.co.uk,amazon.in,amazon.de,amazon.it"
AMAZON_DOMAINS = (
"amazon.com,amazon.ca,amazon.co.uk,amazon.in,amazon.de,amazon.it,amazon.com.au"
)
AMAZON_DELIVERED_SUBJECT = ["Delivered: Your", "Consegna effettuata:"]
AMAZON_SHIPMENT_TRACKING = ["shipment-tracking", "conferma-spedizione"]
AMAZON_EMAIL = "order-update@"
Expand Down Expand Up @@ -208,7 +210,7 @@
},
"auspost_delivering": {
"email": ["[email protected]"],
"subject": ["Your delivery is coming today"],
"subject": ["is on its way", "is coming today"],
},
"auspost_packages": {},
"auspost_tracking": {"pattern": ["\\d{7,10,12}|[A-Za-z]{2}[0-9]{9}AU "]},
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,7 @@ def mock_imap_search_error_none():
mock_conn.select.return_value = ("OK", [])
yield mock_conn


@pytest.fixture()
def mock_imap_amazon_fwd():
"""Mock imap class values."""
Expand Down
26 changes: 10 additions & 16 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ async def test_amazon_search_results(hass, mock_imap_amazon_shipped):
result = amazon_search(
mock_imap_amazon_shipped, "test/path", hass, "testfilename.jpg"
)
assert result == 12
assert result == 14


async def test_amazon_search_delivered(
Expand All @@ -821,7 +821,7 @@ async def test_amazon_search_delivered(
result = amazon_search(
mock_imap_amazon_delivered, "test/path", hass, "testfilename.jpg"
)
assert result == 12
assert result == 14
assert mock_download_img.called


Expand All @@ -831,7 +831,7 @@ async def test_amazon_search_delivered_it(
result = amazon_search(
mock_imap_amazon_delivered_it, "test/path", hass, "testfilename.jpg"
)
assert result == 12
assert result == 14


async def test_amazon_hub(hass, mock_imap_amazon_the_hub):
Expand Down Expand Up @@ -1042,20 +1042,13 @@ async def test_image_file_name(

async def test_amazon_exception(hass, mock_imap_amazon_exception, caplog):
result = amazon_exception(mock_imap_amazon_exception, ['""'])
assert result["order"] == [
"123-1234567-1234567",
"123-1234567-1234567",
"123-1234567-1234567",
"123-1234567-1234567",
"123-1234567-1234567",
"123-1234567-1234567",
]
assert result["count"] == 6
assert result["order"] == ["123-1234567-1234567"] * 7
assert result["count"] == 7

result = amazon_exception(mock_imap_amazon_exception, ["[email protected]"])
assert result["count"] == 7
assert result["count"] == 8
assert (
"Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', '[email protected]']"
"Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', 'amazon.com.au', '[email protected]']"
in caplog.text
)

Expand Down Expand Up @@ -1104,7 +1097,8 @@ async def test_email_search_none(mock_imap_search_error_none, caplog):
)
assert result == ("OK", [b""])

async def test_amazon_shipped_fwd(hass, mock_imap_amazon_fwd,caplog):

async def test_amazon_shipped_fwd(hass, mock_imap_amazon_fwd, caplog):
result = get_items(mock_imap_amazon_fwd, "order")
assert result == ["123-1234567-1234567"]
assert "Arrive Date: Tuesday, January 11" in caplog.text
assert "Arrive Date: Tuesday, January 11" in caplog.text

0 comments on commit 565b17a

Please sign in to comment.