Support reloading the group notify platform (#39511)

This commit is contained in:
J. Nick Koston authored and GitHub committed 2020-09-03 00:12:07 +02:00
1 parent 2d2efeb9bb
commit a778690b64
8 files changed
+470 -129

No files matched your search

+59 -1
View File
@@ -1,11 +1,14 @@
"""The tests for the notify.group platform."""
import asyncio
from os import path
import unittest
from homeassistant import config as hass_config
import homeassistant.components.demo.notify as demo
from homeassistant.components.group import SERVICE_RELOAD
import homeassistant.components.group.notify as group
import homeassistant.components.notify as notify
from homeassistant.setup import setup_component
from homeassistant.setup import async_setup_component, setup_component
from tests.async_mock import MagicMock, patch
from tests.common import assert_setup_component, get_test_home_assistant
@@ -90,3 +93,58 @@ class TestNotifyGroup(unittest.TestCase):
"title": "Test notification",
"data": {"hello": "world", "test": "message"},
}
async def test_reload_notify(hass):
"""Verify we can reload the notify service."""
assert await async_setup_component(
hass,
"group",
{},
)
await hass.async_block_till_done()
assert await async_setup_component(
hass,
notify.DOMAIN,
{
notify.DOMAIN: [
{"name": "demo1", "platform": "demo"},
{"name": "demo2", "platform": "demo"},
{
"name": "group_notify",
"platform": "group",
"services": [{"service": "demo1"}],
},
]
},
)
await hass.async_block_till_done()
assert hass.services.has_service(notify.DOMAIN, "demo1")
assert hass.services.has_service(notify.DOMAIN, "demo2")
assert hass.services.has_service(notify.DOMAIN, "group_notify")
yaml_path = path.join(
_get_fixtures_base_path(),
"fixtures",
"group/configuration.yaml",
)
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call(
"group",
SERVICE_RELOAD,
{},
blocking=True,
)
await hass.async_block_till_done()
assert hass.services.has_service(notify.DOMAIN, "demo1")
assert hass.services.has_service(notify.DOMAIN, "demo2")
assert not hass.services.has_service(notify.DOMAIN, "group_notify")
assert hass.services.has_service(notify.DOMAIN, "new_group_notify")
def _get_fixtures_base_path():
return path.dirname(path.dirname(path.dirname(__file__)))