Add install to Tessie update platform (#106352)

This commit is contained in:
Brett Adams 2023-12-27 07:56:23 +10:00 committed by GitHub
parent 728bef20d6
commit b51a242fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 4 deletions

View file

@ -1,5 +1,12 @@
"""Test the Tessie update platform."""
from homeassistant.const import STATE_ON
from unittest.mock import patch
from homeassistant.components.update import (
ATTR_IN_PROGRESS,
DOMAIN as UPDATE_DOMAIN,
SERVICE_INSTALL,
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_ON
from homeassistant.core import HomeAssistant
from .common import setup_platform
@ -14,4 +21,22 @@ async def test_updates(hass: HomeAssistant) -> None:
assert len(hass.states.async_all("update")) == 1
assert hass.states.get("update.test").state == STATE_ON
entity_id = "update.test"
state = hass.states.get(entity_id)
assert state.state == STATE_ON
assert state.attributes.get(ATTR_IN_PROGRESS) is False
with patch(
"homeassistant.components.tessie.update.schedule_software_update"
) as mock_update:
await hass.services.async_call(
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_update.assert_called_once()
state = hass.states.get(entity_id)
assert state.state == STATE_ON
assert state.attributes.get(ATTR_IN_PROGRESS) == 1