Allow loading of more then 1 defined Apprise URL (#110868)

This commit is contained in:
Chris Caron
2024-02-22 11:37:35 +01:00
committed by Franck Nijhof
parent 6745814e59
commit b7c97880e9
2 changed files with 47 additions and 4 deletions
+42 -1
View File
@@ -118,7 +118,48 @@ async def test_apprise_notification(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
# Validate calls were made under the hood correctly
obj.add.assert_called_once_with([config[BASE_COMPONENT]["url"]])
obj.add.assert_called_once_with(config[BASE_COMPONENT]["url"])
obj.notify.assert_called_once_with(
**{"body": data["message"], "title": data["title"], "tag": None}
)
async def test_apprise_multiple_notification(hass: HomeAssistant) -> None:
"""Test apprise notification."""
config = {
BASE_COMPONENT: {
"name": "test",
"platform": "apprise",
"url": [
"mailto://user:pass@example.com, mailto://user:pass@gmail.com",
"json://user:pass@gmail.com",
],
}
}
# Our Message
data = {"title": "Test Title", "message": "Test Message"}
with patch(
"homeassistant.components.apprise.notify.apprise.Apprise"
) as mock_apprise:
obj = MagicMock()
obj.add.return_value = True
obj.notify.return_value = True
mock_apprise.return_value = obj
assert await async_setup_component(hass, BASE_COMPONENT, config)
await hass.async_block_till_done()
# Test the existence of our service
assert hass.services.has_service(BASE_COMPONENT, "test")
# Test the call to our underlining notify() call
await hass.services.async_call(BASE_COMPONENT, "test", data)
await hass.async_block_till_done()
# Validate 2 calls were made under the hood
assert obj.add.call_count == 2
obj.notify.assert_called_once_with(
**{"body": data["message"], "title": data["title"], "tag": None}
)