mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Fix Litter-Robot 4 firmware versions reported while updating (#85710)
This commit is contained in:
@@ -11,7 +11,13 @@ from homeassistant.components.update import (
|
||||
SERVICE_INSTALL,
|
||||
UpdateDeviceClass,
|
||||
)
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
||||
@@ -28,6 +34,7 @@ async def test_robot_with_no_update(
|
||||
"""Tests the update entity was set up."""
|
||||
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
||||
robot.has_firmware_update = AsyncMock(return_value=False)
|
||||
robot.get_latest_firmware = AsyncMock(return_value=None)
|
||||
|
||||
entry = await setup_integration(
|
||||
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
||||
@@ -79,3 +86,27 @@ async def test_robot_with_update(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert robot.update_firmware.call_count == 1
|
||||
|
||||
|
||||
async def test_robot_with_update_already_in_progress(
|
||||
hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock
|
||||
):
|
||||
"""Tests the update entity was set up."""
|
||||
robot: LitterRobot4 = mock_account_with_litterrobot_4.robots[0]
|
||||
robot._update_data( # pylint:disable=protected-access
|
||||
{"isFirmwareUpdateTriggered": True}, partial=True
|
||||
)
|
||||
|
||||
entry = await setup_integration(
|
||||
hass, mock_account_with_litterrobot_4, PLATFORM_DOMAIN
|
||||
)
|
||||
|
||||
state = hass.states.get(ENTITY_ID)
|
||||
assert state
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == UpdateDeviceClass.FIRMWARE
|
||||
assert state.attributes[ATTR_INSTALLED_VERSION] == OLD_FIRMWARE
|
||||
assert state.attributes[ATTR_LATEST_VERSION] is None
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
Reference in New Issue
Block a user