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:
J. Nick Koston 2023-09-06 04:04:49 -05:00 committed by GitHub
parent 71afa0ff43
commit 034fabe188
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View file

@ -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