Add Save Persistent States service (#53881)

This commit is contained in:
Richard T. Schaefer 2021-08-09 17:38:56 -05:00 committed by GitHub
parent 33c33d844e
commit 3184f0697f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 95 additions and 1 deletions

View file

@ -23,6 +23,7 @@ from homeassistant.const import (
EVENT_CORE_CONFIG_UPDATE,
SERVICE_HOMEASSISTANT_RESTART,
SERVICE_HOMEASSISTANT_STOP,
SERVICE_SAVE_PERSISTENT_STATES,
SERVICE_TOGGLE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
@ -543,3 +544,18 @@ async def test_stop_homeassistant(hass):
assert not mock_check.called
await hass.async_block_till_done()
assert mock_restart.called
async def test_save_persistent_states(hass):
"""Test we can call save_persistent_states."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.helpers.restore_state.RestoreStateData.async_save_persistent_states",
return_value=None,
) as mock_save:
await hass.services.async_call(
"homeassistant",
SERVICE_SAVE_PERSISTENT_STATES,
blocking=True,
)
assert mock_save.called