Add reproduce state support to input_boolean (#25858)
* Add reproduce state support to input_boolean * Catch unknown state
This commit is contained in:
1 parent
6f357cb23e
commit
172bbf806d
2 files changed
+98
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"""Test reproduce state for input boolean."""
|
||||
from homeassistant.core import State
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_reproducing_states(hass):
|
||||
"""Test reproducing input_boolean states."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
"input_boolean",
|
||||
{
|
||||
"input_boolean": {
|
||||
"initial_on": {"initial": True},
|
||||
"initial_off": {"initial": False},
|
||||
}
|
||||
},
|
||||
)
|
||||
await hass.helpers.state.async_reproduce_state(
|
||||
[
|
||||
State("input_boolean.initial_on", "off"),
|
||||
State("input_boolean.initial_off", "on"),
|
||||
# Should not raise
|
||||
State("input_boolean.non_existing", "on"),
|
||||
],
|
||||
blocking=True,
|
||||
)
|
||||
assert hass.states.get("input_boolean.initial_off").state == "on"
|
||||
assert hass.states.get("input_boolean.initial_on").state == "off"
|
||||
|
||||
await hass.helpers.state.async_reproduce_state(
|
||||
[
|
||||
# Test invalid state
|
||||
State("input_boolean.initial_on", "invalid_state"),
|
||||
# Set to state it already is.
|
||||
State("input_boolean.initial_off", "on"),
|
||||
],
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert hass.states.get("input_boolean.initial_on").state == "off"
|
||||
assert hass.states.get("input_boolean.initial_off").state == "on"
|
||||
Reference in new issue
Block a user