Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for firmware update scenario #103314

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading