mirror of
https://github.com/elisspace/core.git
synced 2026-08-29 15:43:55 +00:00
coverage
This commit is contained in:
@@ -63,6 +63,7 @@ from homeassistant.helpers import (
|
||||
restore_state,
|
||||
restore_state as rs,
|
||||
storage,
|
||||
template,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
@@ -267,6 +268,7 @@ async def async_test_home_assistant(event_loop, load_registries=True):
|
||||
ir.async_load(hass),
|
||||
rs.async_load(hass),
|
||||
)
|
||||
template.async_setup(hass)
|
||||
hass.data[bootstrap.DATA_REGISTRIES_LOADED] = None
|
||||
|
||||
hass.state = CoreState.running
|
||||
|
||||
@@ -4,6 +4,7 @@ import pytest
|
||||
import homeassistant.components.persistent_notification as pn
|
||||
from homeassistant.components.websocket_api.const import TYPE_RESULT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.template import Template
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.typing import WebSocketGenerator
|
||||
@@ -15,6 +16,29 @@ async def setup_integration(hass):
|
||||
assert await async_setup_component(hass, pn.DOMAIN, {})
|
||||
|
||||
|
||||
async def test_template_usage(hass: HomeAssistant) -> None:
|
||||
"""Test enumerating persistent notifications in a template."""
|
||||
await hass.services.async_call(
|
||||
pn.DOMAIN,
|
||||
"create",
|
||||
{"notification_id": "Beer 2", "message": "test"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
result = Template("{{ persistent_notifications() | count }}", hass).async_render()
|
||||
assert result == 1
|
||||
|
||||
await hass.services.async_call(
|
||||
pn.DOMAIN,
|
||||
"dismiss",
|
||||
{"notification_id": "Beer 2"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
result = Template("{{ persistent_notifications() | count }}", hass).async_render()
|
||||
assert result == 0
|
||||
|
||||
|
||||
async def test_create(hass: HomeAssistant) -> None:
|
||||
"""Test creating notification without title or notification id."""
|
||||
notifications = pn._async_get_or_create_notifications(hass)
|
||||
|
||||
Reference in New Issue
Block a user