Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions tests/components/apprise/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ async def test_apprise_config_load_fail01(hass: HomeAssistant) -> None:
BASE_COMPONENT: {"name": "test", "platform": "apprise", "config": "/path/"}
}

with patch("apprise.AppriseConfig.add", return_value=False):
with patch(
"homeassistant.components.apprise.notify.apprise.AppriseConfig.add",
return_value=False,
):
assert await async_setup_component(hass, BASE_COMPONENT, config)
await hass.async_block_till_done()

Expand All @@ -30,8 +33,12 @@ async def test_apprise_config_load_fail02(hass: HomeAssistant) -> None:
BASE_COMPONENT: {"name": "test", "platform": "apprise", "config": "/path/"}
}

with patch("apprise.Apprise.add", return_value=False), patch(
"apprise.AppriseConfig.add", return_value=True
with patch(
"homeassistant.components.apprise.notify.apprise.Apprise.add",
return_value=False,
), patch(
"homeassistant.components.apprise.notify.apprise.AppriseConfig.add",
return_value=True,
):
assert await async_setup_component(hass, BASE_COMPONENT, config)
await hass.async_block_till_done()
Expand Down Expand Up @@ -68,7 +75,10 @@ async def test_apprise_url_load_fail(hass: HomeAssistant) -> None:
"url": "mailto://user:pass@example.com",
}
}
with patch("apprise.Apprise.add", return_value=False):
with patch(
"homeassistant.components.apprise.notify.apprise.Apprise.add",
return_value=False,
):
assert await async_setup_component(hass, BASE_COMPONENT, config)
await hass.async_block_till_done()

Expand All @@ -90,7 +100,9 @@ async def test_apprise_notification(hass: HomeAssistant) -> None:
# Our Message
data = {"title": "Test Title", "message": "Test Message"}

with patch("apprise.Apprise") as mock_apprise:
with patch(
"homeassistant.components.apprise.notify.apprise.Apprise"
) as mock_apprise:
obj = MagicMock()
obj.add.return_value = True
obj.notify.return_value = True
Expand Down Expand Up @@ -131,7 +143,9 @@ async def test_apprise_notification_with_target(
# Our Message, only notify the services tagged with "devops"
data = {"title": "Test Title", "message": "Test Message", "target": ["devops"]}

with patch("apprise.Apprise") as mock_apprise:
with patch(
"homeassistant.components.apprise.notify.apprise.Apprise"
) as mock_apprise:
apprise_obj = MagicMock()
apprise_obj.add.return_value = True
apprise_obj.notify.return_value = True
Expand Down