Use loop time to set context (#99701)
* Use loop time to set context loop time is faster than utcnow, and since its only used internally it can be switched without a breaking change * fix mocking
This commit is contained in:
parent
71afa0ff43
commit
034fabe188
2 changed files with 10 additions and 8 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Test service helpers."""
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Iterable
|
||||
from copy import deepcopy
|
||||
from typing import Any
|
||||
|
@ -54,7 +53,7 @@ def mock_handle_entity_call():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_entities(hass):
|
||||
def mock_entities(hass: HomeAssistant) -> dict[str, MockEntity]:
|
||||
"""Return mock entities in an ordered dict."""
|
||||
kitchen = MockEntity(
|
||||
entity_id="light.kitchen",
|
||||
|
@ -80,11 +79,13 @@ def mock_entities(hass):
|
|||
should_poll=False,
|
||||
supported_features=(SUPPORT_B | SUPPORT_C),
|
||||
)
|
||||
entities = OrderedDict()
|
||||
entities = {}
|
||||
entities[kitchen.entity_id] = kitchen
|
||||
entities[living_room.entity_id] = living_room
|
||||
entities[bedroom.entity_id] = bedroom
|
||||
entities[bathroom.entity_id] = bathroom
|
||||
for entity in entities.values():
|
||||
entity.hass = hass
|
||||
return entities
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue