2020-09-02 18:25:43 -05:00
|
|
|
"""The tests for the rest.notify platform."""
|
2021-01-01 22:31:56 +01:00
|
|
|
from unittest.mock import patch
|
2020-09-02 18:25:43 -05:00
|
|
|
|
2021-02-19 19:44:15 -10:00
|
|
|
import respx
|
|
|
|
|
2020-09-02 18:25:43 -05:00
|
|
|
from homeassistant import config as hass_config
|
|
|
|
import homeassistant.components.notify as notify
|
|
|
|
from homeassistant.components.rest import DOMAIN
|
|
|
|
from homeassistant.const import SERVICE_RELOAD
|
2022-10-31 15:30:29 +01:00
|
|
|
from homeassistant.core import HomeAssistant
|
2020-09-02 18:25:43 -05:00
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
|
2021-11-01 20:47:05 -07:00
|
|
|
from tests.common import get_fixture_path
|
|
|
|
|
2020-09-02 18:25:43 -05:00
|
|
|
|
2021-02-19 19:44:15 -10:00
|
|
|
@respx.mock
|
2022-10-31 15:30:29 +01:00
|
|
|
async def test_reload_notify(hass: HomeAssistant) -> None:
|
2020-09-02 18:25:43 -05:00
|
|
|
"""Verify we can reload the notify service."""
|
2021-02-19 19:44:15 -10:00
|
|
|
respx.get("http://localhost") % 200
|
2020-09-02 18:25:43 -05:00
|
|
|
|
|
|
|
assert await async_setup_component(
|
|
|
|
hass,
|
|
|
|
notify.DOMAIN,
|
|
|
|
{
|
|
|
|
notify.DOMAIN: [
|
|
|
|
{
|
|
|
|
"name": DOMAIN,
|
|
|
|
"platform": DOMAIN,
|
|
|
|
"resource": "http://127.0.0.1/off",
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert hass.services.has_service(notify.DOMAIN, DOMAIN)
|
|
|
|
|
2021-11-01 20:47:05 -07:00
|
|
|
yaml_path = get_fixture_path("configuration.yaml", "rest")
|
|
|
|
|
2020-09-02 18:25:43 -05:00
|
|
|
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
|
|
|
|
await hass.services.async_call(
|
|
|
|
DOMAIN,
|
|
|
|
SERVICE_RELOAD,
|
|
|
|
{},
|
|
|
|
blocking=True,
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
assert not hass.services.has_service(notify.DOMAIN, DOMAIN)
|
|
|
|
assert hass.services.has_service(notify.DOMAIN, "rest_reloaded")
|