Handle all firmware types for ZBT-1 and Yellow update entities (#141674)

Handle other firmware types
This commit is contained in:
puddly
2025-03-28 15:38:16 -04:00
committed by GitHub
parent 17c56208ee
commit 5283e1a39f
5 changed files with 163 additions and 7 deletions

View File

@@ -2,6 +2,8 @@
from unittest.mock import patch
import pytest
from homeassistant.components.homeassistant_hardware.helpers import (
async_notify_firmware_info,
)
@@ -90,3 +92,53 @@ async def test_yellow_update_entity(hass: HomeAssistant) -> None:
assert state_spinel.attributes["title"] == "OpenThread RCP"
assert state_spinel.attributes["installed_version"] == "2.4.4.0"
assert state_spinel.attributes["latest_version"] is None
@pytest.mark.parametrize(
("firmware", "version", "expected"),
[
("ezsp", "7.3.1.0 build 0", "EmberZNet Zigbee 7.3.1.0"),
("spinel", "SL-OPENTHREAD/2.4.4.0_GitHub-7074a43e4", "OpenThread RCP 2.4.4.0"),
("bootloader", "2.4.2", "Gecko Bootloader 2.4.2"),
("cpc", "4.3.2", "Multiprotocol 4.3.2"),
("router", "1.2.3.4", "Unknown 1.2.3.4"), # Not supported but still shown
],
)
async def test_yellow_update_entity_state(
hass: HomeAssistant, firmware: str, version: str, expected: str
) -> None:
"""Test the Yellow firmware update entity with different firmware types."""
await async_setup_component(hass, "homeassistant", {})
# Set up the Yellow integration
yellow_config_entry = MockConfigEntry(
title="Home Assistant Yellow",
domain="homeassistant_yellow",
data={
"firmware": firmware,
"firmware_version": version,
"device": RADIO_DEVICE,
},
version=1,
minor_version=3,
)
yellow_config_entry.add_to_hass(hass)
with (
patch(
"homeassistant.components.homeassistant_yellow.is_hassio", return_value=True
),
patch(
"homeassistant.components.homeassistant_yellow.get_os_info",
return_value={"board": "yellow"},
),
):
assert await hass.config_entries.async_setup(yellow_config_entry.entry_id)
await hass.async_block_till_done()
state = hass.states.get(UPDATE_ENTITY_ID)
assert state is not None
assert (
f"{state.attributes['title']} {state.attributes['installed_version']}"
== expected
)