Fix apprise tests for python 3.11 (#88126)

This commit is contained in:
J. Nick Koston 2023-02-14 14:25:25 -06:00 committed by GitHub
parent 2e74e75177
commit 44e8e808a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
@ -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()
@ -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()
@ -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
@ -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