mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix apprise tests for python 3.11 (#88126)
This commit is contained in:
parent
2e74e75177
commit
44e8e808a1
@ -15,7 +15,10 @@ async def test_apprise_config_load_fail01(hass: HomeAssistant) -> None:
|
|||||||
BASE_COMPONENT: {"name": "test", "platform": "apprise", "config": "/path/"}
|
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)
|
assert await async_setup_component(hass, BASE_COMPONENT, config)
|
||||||
await hass.async_block_till_done()
|
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/"}
|
BASE_COMPONENT: {"name": "test", "platform": "apprise", "config": "/path/"}
|
||||||
}
|
}
|
||||||
|
|
||||||
with patch("apprise.Apprise.add", return_value=False), patch(
|
with patch(
|
||||||
"apprise.AppriseConfig.add", return_value=True
|
"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)
|
assert await async_setup_component(hass, BASE_COMPONENT, config)
|
||||||
await hass.async_block_till_done()
|
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",
|
"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)
|
assert await async_setup_component(hass, BASE_COMPONENT, config)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -90,7 +100,9 @@ async def test_apprise_notification(hass: HomeAssistant) -> None:
|
|||||||
# Our Message
|
# Our Message
|
||||||
data = {"title": "Test Title", "message": "Test 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 = MagicMock()
|
||||||
obj.add.return_value = True
|
obj.add.return_value = True
|
||||||
obj.notify.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"
|
# Our Message, only notify the services tagged with "devops"
|
||||||
data = {"title": "Test Title", "message": "Test Message", "target": ["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 = MagicMock()
|
||||||
apprise_obj.add.return_value = True
|
apprise_obj.add.return_value = True
|
||||||
apprise_obj.notify.return_value = True
|
apprise_obj.notify.return_value = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user