mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Move manual trigger entity tests (#130134)
This commit is contained in:
40
tests/helpers/test_trigger_template_entity.py
Normal file
40
tests/helpers/test_trigger_template_entity.py
Normal file
@ -0,0 +1,40 @@
|
||||
"""Test template trigger entity."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import template
|
||||
from homeassistant.helpers.trigger_template_entity import ManualTriggerEntity
|
||||
|
||||
|
||||
async def test_template_entity_requires_hass_set(hass: HomeAssistant) -> None:
|
||||
"""Test manual trigger template entity."""
|
||||
config = {
|
||||
"name": template.Template("test_entity", hass),
|
||||
"icon": template.Template(
|
||||
'{% if value=="on" %} mdi:on {% else %} mdi:off {% endif %}', hass
|
||||
),
|
||||
"picture": template.Template(
|
||||
'{% if value=="on" %} /local/picture_on {% else %} /local/picture_off {% endif %}',
|
||||
hass,
|
||||
),
|
||||
}
|
||||
|
||||
entity = ManualTriggerEntity(hass, config)
|
||||
entity.entity_id = "test.entity"
|
||||
hass.states.async_set("test.entity", "on")
|
||||
await entity.async_added_to_hass()
|
||||
|
||||
entity._process_manual_data("on")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entity.name == "test_entity"
|
||||
assert entity.icon == "mdi:on"
|
||||
assert entity.entity_picture == "/local/picture_on"
|
||||
|
||||
hass.states.async_set("test.entity", "off")
|
||||
await entity.async_added_to_hass()
|
||||
entity._process_manual_data("off")
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entity.name == "test_entity"
|
||||
assert entity.icon == "mdi:off"
|
||||
assert entity.entity_picture == "/local/picture_off"
|
Reference in New Issue
Block a user