mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Refactor logbook to reduce overhead and complexity (#71509)
This commit is contained in:
@@ -6,7 +6,6 @@ from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import logbook
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.automation import (
|
||||
ATTR_SOURCE,
|
||||
@@ -53,7 +52,7 @@ from tests.common import (
|
||||
async_mock_service,
|
||||
mock_restore_cache,
|
||||
)
|
||||
from tests.components.logbook.test_init import MockLazyEventPartialState
|
||||
from tests.components.logbook.common import MockRow, mock_humanify
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -1223,28 +1222,23 @@ async def test_logbook_humanify_automation_triggered_event(hass):
|
||||
hass.config.components.add("recorder")
|
||||
await async_setup_component(hass, automation.DOMAIN, {})
|
||||
await async_setup_component(hass, "logbook", {})
|
||||
entity_attr_cache = logbook.EntityAttributeCache(hass)
|
||||
|
||||
event1, event2 = list(
|
||||
logbook.humanify(
|
||||
hass,
|
||||
[
|
||||
MockLazyEventPartialState(
|
||||
EVENT_AUTOMATION_TRIGGERED,
|
||||
{ATTR_ENTITY_ID: "automation.hello", ATTR_NAME: "Hello Automation"},
|
||||
),
|
||||
MockLazyEventPartialState(
|
||||
EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
ATTR_ENTITY_ID: "automation.bye",
|
||||
ATTR_NAME: "Bye Automation",
|
||||
ATTR_SOURCE: "source of trigger",
|
||||
},
|
||||
),
|
||||
],
|
||||
entity_attr_cache,
|
||||
{},
|
||||
)
|
||||
event1, event2 = mock_humanify(
|
||||
hass,
|
||||
[
|
||||
MockRow(
|
||||
EVENT_AUTOMATION_TRIGGERED,
|
||||
{ATTR_ENTITY_ID: "automation.hello", ATTR_NAME: "Hello Automation"},
|
||||
),
|
||||
MockRow(
|
||||
EVENT_AUTOMATION_TRIGGERED,
|
||||
{
|
||||
ATTR_ENTITY_ID: "automation.bye",
|
||||
ATTR_NAME: "Bye Automation",
|
||||
ATTR_SOURCE: "source of trigger",
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
assert event1["name"] == "Hello Automation"
|
||||
|
||||
Reference in New Issue
Block a user