Add test for firmware update scenario (#103314)

This commit is contained in:
Raman Gupta 2023-11-04 08:12:06 -04:00 committed by GitHub
parent fa6d8d281d
commit 2b3d57859e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View file

@ -333,6 +333,10 @@ class ZWaveNodeFirmwareUpdate(UpdateEntity):
)
)
# 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())

View file

@ -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,