mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
Reduce overhead to call entity services (#106908)
This commit is contained in:
@@ -19,7 +19,13 @@ from homeassistant.const import (
|
||||
STATE_ON,
|
||||
EntityCategory,
|
||||
)
|
||||
from homeassistant.core import Context, HomeAssistant, ServiceCall, SupportsResponse
|
||||
from homeassistant.core import (
|
||||
Context,
|
||||
HassJob,
|
||||
HomeAssistant,
|
||||
ServiceCall,
|
||||
SupportsResponse,
|
||||
)
|
||||
from homeassistant.helpers import (
|
||||
device_registry as dr,
|
||||
entity_registry as er,
|
||||
@@ -803,7 +809,7 @@ async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
mock_entities,
|
||||
test_service_mock,
|
||||
HassJob(test_service_mock),
|
||||
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
||||
required_features=[SUPPORT_A],
|
||||
)
|
||||
@@ -822,7 +828,7 @@ async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
mock_entities,
|
||||
test_service_mock,
|
||||
HassJob(test_service_mock),
|
||||
ServiceCall(
|
||||
"test_domain", "test_service", {"entity_id": "light.living_room"}
|
||||
),
|
||||
@@ -839,7 +845,7 @@ async def test_call_with_both_required_features(
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
mock_entities,
|
||||
test_service_mock,
|
||||
HassJob(test_service_mock),
|
||||
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
||||
required_features=[SUPPORT_A | SUPPORT_B],
|
||||
)
|
||||
@@ -858,7 +864,7 @@ async def test_call_with_one_of_required_features(
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
mock_entities,
|
||||
test_service_mock,
|
||||
HassJob(test_service_mock),
|
||||
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
||||
required_features=[SUPPORT_A, SUPPORT_C],
|
||||
)
|
||||
@@ -879,7 +885,7 @@ async def test_call_with_sync_func(hass: HomeAssistant, mock_entities) -> None:
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
mock_entities,
|
||||
test_service_mock,
|
||||
HassJob(test_service_mock),
|
||||
ServiceCall("test_domain", "test_service", {"entity_id": "light.kitchen"}),
|
||||
)
|
||||
assert test_service_mock.call_count == 1
|
||||
|
||||
Reference in New Issue
Block a user