mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 02:19:31 +00:00
Co-authored-by: G Johansson <goran.johansson@shiftit.se> Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: abmantis <amfcalt@gmail.com>
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""The tests for the telegram.notify platform."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from homeassistant import config as hass_config
|
|
from homeassistant.components import notify
|
|
from homeassistant.components.telegram import DOMAIN
|
|
from homeassistant.const import SERVICE_RELOAD
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import issue_registry as ir
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from tests.common import get_fixture_path
|
|
|
|
|
|
async def test_reload_notify(
|
|
hass: HomeAssistant, issue_registry: ir.IssueRegistry
|
|
) -> None:
|
|
"""Verify we can reload the notify service."""
|
|
|
|
with patch("homeassistant.components.telegram_bot.async_setup", return_value=True):
|
|
assert await async_setup_component(
|
|
hass,
|
|
notify.DOMAIN,
|
|
{
|
|
notify.DOMAIN: [
|
|
{
|
|
"name": DOMAIN,
|
|
"platform": DOMAIN,
|
|
"chat_id": 1,
|
|
},
|
|
]
|
|
},
|
|
)
|
|
await hass.async_block_till_done()
|
|
|
|
assert hass.services.has_service(notify.DOMAIN, DOMAIN)
|
|
|
|
yaml_path = get_fixture_path("configuration.yaml", "telegram")
|
|
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, "telegram_reloaded")
|
|
|
|
assert issue_registry.async_get_issue(
|
|
domain=DOMAIN,
|
|
issue_id="migrate_notify",
|
|
)
|
|
assert len(issue_registry.issues) == 1
|