Skip to content

Commit

Permalink
Add test for firmware update scenario (#103314)
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Nov 4, 2023
1 parent fa6d8d2 commit 2b3d578
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions homeassistant/components/zwave_js/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ async def async_added_to_hass(self) -> None:
)
)

# Make sure these variables are set for the elif evaluation
state = None
latest_version = None

# If we have a complete previous state, use that to set the latest version
if (
(state := await self.async_get_last_state())
Expand Down
36 changes: 36 additions & 0 deletions tests/components/zwave_js/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,42 @@ async def test_update_entity_partial_restore_data(
assert state.state == STATE_UNKNOWN


async def test_update_entity_partial_restore_data_2(
hass: HomeAssistant,
client,
climate_radio_thermostat_ct100_plus_different_endpoints,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test second scenario where update entity has partial restore data."""
mock_restore_cache_with_extra_data(
hass,
[
(
State(
UPDATE_ENTITY,
STATE_ON,
{
ATTR_INSTALLED_VERSION: "10.7",
ATTR_LATEST_VERSION: "10.8",
ATTR_SKIPPED_VERSION: None,
},
),
{"latest_version_firmware": None},
)
],
)
entry = MockConfigEntry(domain="zwave_js", data={"url": "ws://test.org"})
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()

state = hass.states.get(UPDATE_ENTITY)
assert state
assert state.state == STATE_UNKNOWN
assert state.attributes[ATTR_SKIPPED_VERSION] is None
assert state.attributes[ATTR_LATEST_VERSION] is None


async def test_update_entity_full_restore_data_skipped_version(
hass: HomeAssistant,
client,
Expand Down

0 comments on commit 2b3d578

Please sign in to comment.