mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Clean up async_reproduce_state helper usage (#68617)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Test reproduce state for Automation."""
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers.state import async_reproduce_state
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
||||
@@ -13,30 +14,30 @@ async def test_reproducing_states(hass, caplog):
|
||||
turn_off_calls = async_mock_service(hass, "automation", "turn_off")
|
||||
|
||||
# These calls should do nothing as entities already in desired state
|
||||
await hass.helpers.state.async_reproduce_state(
|
||||
[State("automation.entity_off", "off"), State("automation.entity_on", "on")]
|
||||
await async_reproduce_state(
|
||||
hass,
|
||||
[State("automation.entity_off", "off"), State("automation.entity_on", "on")],
|
||||
)
|
||||
|
||||
assert len(turn_on_calls) == 0
|
||||
assert len(turn_off_calls) == 0
|
||||
|
||||
# Test invalid state is handled
|
||||
await hass.helpers.state.async_reproduce_state(
|
||||
[State("automation.entity_off", "not_supported")]
|
||||
)
|
||||
await async_reproduce_state(hass, [State("automation.entity_off", "not_supported")])
|
||||
|
||||
assert "not_supported" in caplog.text
|
||||
assert len(turn_on_calls) == 0
|
||||
assert len(turn_off_calls) == 0
|
||||
|
||||
# Make sure correct services are called
|
||||
await hass.helpers.state.async_reproduce_state(
|
||||
await async_reproduce_state(
|
||||
hass,
|
||||
[
|
||||
State("automation.entity_on", "off"),
|
||||
State("automation.entity_off", "on"),
|
||||
# Should not raise
|
||||
State("automation.non_existing", "on"),
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
assert len(turn_on_calls) == 1
|
||||
|
||||
Reference in New Issue
Block a user