mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 10:18:11 +02:00
Refactor logbook to reduce overhead and complexity (#71509)
This commit is contained in:
@ -6,7 +6,7 @@ from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import logbook, script
|
||||
from homeassistant.components import script
|
||||
from homeassistant.components.script import DOMAIN, EVENT_SCRIPT_STARTED
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
@ -41,7 +41,7 @@ from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed, async_mock_service, mock_restore_cache
|
||||
from tests.components.logbook.test_init import MockLazyEventPartialState
|
||||
from tests.components.logbook.common import MockRow, mock_humanify
|
||||
|
||||
ENTITY_ID = "script.test"
|
||||
|
||||
@ -526,24 +526,19 @@ async def test_logbook_humanify_script_started_event(hass):
|
||||
hass.config.components.add("recorder")
|
||||
await async_setup_component(hass, DOMAIN, {})
|
||||
await async_setup_component(hass, "logbook", {})
|
||||
entity_attr_cache = logbook.EntityAttributeCache(hass)
|
||||
|
||||
event1, event2 = list(
|
||||
logbook.humanify(
|
||||
hass,
|
||||
[
|
||||
MockLazyEventPartialState(
|
||||
EVENT_SCRIPT_STARTED,
|
||||
{ATTR_ENTITY_ID: "script.hello", ATTR_NAME: "Hello Script"},
|
||||
),
|
||||
MockLazyEventPartialState(
|
||||
EVENT_SCRIPT_STARTED,
|
||||
{ATTR_ENTITY_ID: "script.bye", ATTR_NAME: "Bye Script"},
|
||||
),
|
||||
],
|
||||
entity_attr_cache,
|
||||
{},
|
||||
)
|
||||
event1, event2 = mock_humanify(
|
||||
hass,
|
||||
[
|
||||
MockRow(
|
||||
EVENT_SCRIPT_STARTED,
|
||||
{ATTR_ENTITY_ID: "script.hello", ATTR_NAME: "Hello Script"},
|
||||
),
|
||||
MockRow(
|
||||
EVENT_SCRIPT_STARTED,
|
||||
{ATTR_ENTITY_ID: "script.bye", ATTR_NAME: "Bye Script"},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
assert event1["name"] == "Hello Script"
|
||||
|
Reference in New Issue
Block a user