Skip to content

Commit

Permalink
feat: add amazon.fr to amazon sensor (#784)
Browse files Browse the repository at this point in the history
* feat: add amazon.fr to amazon sensor

* add missing date check start

* update tests
  • Loading branch information
firstof9 authored Jan 5, 2023
1 parent 6f36d7a commit 1c24dec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions custom_components/mail_and_packages/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,21 @@
"amazon.com.au",
"amazon.pl",
"amazon.es",
"amazon.fr",
]
AMAZON_DELIVERED_SUBJECT = [
"Delivered: Your",
"Consegna effettuata:",
"Dostarczono:",
"Geliefert:",
"Livré",
]
AMAZON_SHIPMENT_TRACKING = [
"shipment-tracking",
"conferma-spedizione",
"confirmar-envio",
"versandbestaetigung",
"confirmation-commande",
]
AMAZON_EMAIL = "order-update@"
AMAZON_PACKAGES = "amazon_packages"
Expand All @@ -119,6 +122,7 @@
"Zustellung:",
"Entrega:",
"A chegar:",
"Arrivée :",
]
AMAZON_EXCEPTION_SUBJECT = "Delivery update:"
AMAZON_EXCEPTION_BODY = "running late"
Expand Down
2 changes: 2 additions & 0 deletions custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,8 @@ def get_items(
end = email_msg.find("Sguimiento")
elif email_msg.find("Verfolge deine(n) Artikel") != -1:
end = email_msg.find("Verfolge deine(n) Artikel")
elif email_msg.find("Suivre") != -1:
end = email_msg.find("Suivre")

arrive_date = email_msg[start:end].replace(">", "").strip()
_LOGGER.debug("First pass: %s", arrive_date)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,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 == 44
assert result == 48


@pytest.mark.asyncio
Expand All @@ -879,7 +879,7 @@ async def test_amazon_search_delivered(
result = amazon_search(
mock_imap_amazon_delivered, "test/path", hass, "testfilename.jpg"
)
assert result == 44
assert result == 48
assert mock_download_img.called


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


@pytest.mark.asyncio
Expand Down Expand Up @@ -1120,13 +1120,13 @@ async def test_image_file_name(
@pytest.mark.asyncio
async def test_amazon_exception(hass, mock_imap_amazon_exception, caplog):
result = amazon_exception(mock_imap_amazon_exception, ['""'])
assert result["order"] == ["123-1234567-1234567"] * 11
assert result["count"] == 11
assert result["order"] == ["123-1234567-1234567"] * 12
assert result["count"] == 12

result = amazon_exception(mock_imap_amazon_exception, ["testemail@fakedomain.com"])
assert result["count"] == 12
assert result["count"] == 13
assert (
"Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', 'amazon.com.au', 'amazon.pl', 'amazon.es', 'fakeuser@fake.email', 'fakeuser2@fake.email', 'testemail@fakedomain.com']"
"Amazon domains to be checked: ['amazon.com', 'amazon.ca', 'amazon.co.uk', 'amazon.in', 'amazon.de', 'amazon.it', 'amazon.com.au', 'amazon.pl', 'amazon.es', 'amazon.fr', 'fakeuser@fake.email', 'fakeuser2@fake.email', 'testemail@fakedomain.com']"
in caplog.text
)

Expand Down

0 comments on commit 1c24dec

Please sign in to comment.