Skip to content

Commit

Permalink
use restore_cache helper
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4nt0r committed Dec 18, 2024
1 parent c8b237e commit 6c6edba
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions tests/components/iron_os/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.core import HomeAssistant, State
from homeassistant.helpers import entity_registry as er

from tests.common import MockConfigEntry, snapshot_platform
from tests.common import MockConfigEntry, mock_restore_cache, snapshot_platform
from tests.typing import WebSocketGenerator


Expand Down Expand Up @@ -87,21 +87,23 @@ async def test_update_restore_last_state(
"""Test update entity restore last state."""

mock_pynecil.get_device_info.side_effect = CommunicationError
with patch(
"homeassistant.components.iron_os.update.IronOSUpdate.async_get_last_state",
return_value=State(
"update.pinecil_firmware",
STATE_ON,
attributes={ATTR_INSTALLED_VERSION: "v2.21"},
mock_restore_cache(
hass,
(
State(
"update.pinecil_firmware",
STATE_ON,
attributes={ATTR_INSTALLED_VERSION: "v2.21"},
),
),
):
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
)
config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()

assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

state = hass.states.get("update.pinecil_firmware")
assert state is not None
assert state.state == STATE_ON
assert state.attributes[ATTR_INSTALLED_VERSION] == "v2.21"
state = hass.states.get("update.pinecil_firmware")
assert state is not None
assert state.state == STATE_ON
assert state.attributes[ATTR_INSTALLED_VERSION] == "v2.21"

0 comments on commit 6c6edba

Please sign in to comment.