mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 10:29:27 +00:00
Refactor logbook to reduce overhead and complexity (#71509)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""Test automation logbook."""
|
||||
from homeassistant.components import automation, logbook
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.components.logbook.test_init import MockLazyEventPartialState
|
||||
from tests.components.logbook.common import MockRow, mock_humanify
|
||||
|
||||
|
||||
async def test_humanify_automation_trigger_event(hass):
|
||||
@@ -11,34 +11,29 @@ async def test_humanify_automation_trigger_event(hass):
|
||||
hass.config.components.add("recorder")
|
||||
assert await async_setup_component(hass, "automation", {})
|
||||
assert await async_setup_component(hass, "logbook", {})
|
||||
entity_attr_cache = logbook.EntityAttributeCache(hass)
|
||||
context = Context()
|
||||
|
||||
event1, event2 = list(
|
||||
logbook.humanify(
|
||||
hass,
|
||||
[
|
||||
MockLazyEventPartialState(
|
||||
automation.EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
"name": "Bla",
|
||||
"entity_id": "automation.bla",
|
||||
"source": "state change of input_boolean.yo",
|
||||
},
|
||||
context=context,
|
||||
),
|
||||
MockLazyEventPartialState(
|
||||
automation.EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
"name": "Bla",
|
||||
"entity_id": "automation.bla",
|
||||
},
|
||||
context=context,
|
||||
),
|
||||
],
|
||||
entity_attr_cache,
|
||||
{},
|
||||
)
|
||||
event1, event2 = mock_humanify(
|
||||
hass,
|
||||
[
|
||||
MockRow(
|
||||
automation.EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
"name": "Bla",
|
||||
"entity_id": "automation.bla",
|
||||
"source": "state change of input_boolean.yo",
|
||||
},
|
||||
context=context,
|
||||
),
|
||||
MockRow(
|
||||
automation.EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
"name": "Bla",
|
||||
"entity_id": "automation.bla",
|
||||
},
|
||||
context=context,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
assert event1["name"] == "Bla"
|
||||
|
||||
Reference in New Issue
Block a user