mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use snapshot in devolo_home_network update tests (#101442)
This commit is contained in:
parent
62ea4b36cd
commit
285ad10624
@ -0,0 +1,54 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_update_firmware
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'auto_update': False,
|
||||||
|
'device_class': 'firmware',
|
||||||
|
'entity_picture': 'https://brands.home-assistant.io/_/devolo_home_network/icon.png',
|
||||||
|
'friendly_name': 'Mock Title Firmware',
|
||||||
|
'in_progress': False,
|
||||||
|
'installed_version': '5.6.1',
|
||||||
|
'latest_version': '5.6.2',
|
||||||
|
'release_summary': None,
|
||||||
|
'release_url': None,
|
||||||
|
'skipped_version': None,
|
||||||
|
'supported_features': <UpdateEntityFeature: 5>,
|
||||||
|
'title': None,
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'update.mock_title_firmware',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'on',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_update_firmware.1
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': None,
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'update',
|
||||||
|
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||||
|
'entity_id': 'update.mock_title_firmware',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': <UpdateDeviceClass.FIRMWARE: 'firmware'>,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Firmware',
|
||||||
|
'platform': 'devolo_home_network',
|
||||||
|
'supported_features': <UpdateEntityFeature: 5>,
|
||||||
|
'translation_key': 'regular_firmware',
|
||||||
|
'unique_id': '1234567890_regular_firmware',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
@ -3,25 +3,20 @@ from devolo_plc_api.device_api import UPDATE_NOT_AVAILABLE, UpdateFirmwareCheck
|
|||||||
from devolo_plc_api.exceptions.device import DevicePasswordProtected, DeviceUnavailable
|
from devolo_plc_api.exceptions.device import DevicePasswordProtected, DeviceUnavailable
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.devolo_home_network.const import (
|
from homeassistant.components.devolo_home_network.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
FIRMWARE_UPDATE_INTERVAL,
|
FIRMWARE_UPDATE_INTERVAL,
|
||||||
)
|
)
|
||||||
from homeassistant.components.update import (
|
from homeassistant.components.update import DOMAIN as PLATFORM, SERVICE_INSTALL
|
||||||
DOMAIN as PLATFORM,
|
|
||||||
SERVICE_INSTALL,
|
|
||||||
UpdateDeviceClass,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH
|
from homeassistant.config_entries import SOURCE_REAUTH
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_UNAVAILABLE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity import EntityCategory
|
|
||||||
|
|
||||||
from . import configure_integration
|
from . import configure_integration
|
||||||
from .const import FIRMWARE_UPDATE_AVAILABLE
|
|
||||||
from .mock import MockDevice
|
from .mock import MockDevice
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
@ -45,6 +40,7 @@ async def test_update_firmware(
|
|||||||
mock_device: MockDevice,
|
mock_device: MockDevice,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
freezer: FrozenDateTimeFactory,
|
freezer: FrozenDateTimeFactory,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test updating a device."""
|
"""Test updating a device."""
|
||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
@ -54,17 +50,8 @@ async def test_update_firmware(
|
|||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get(state_key)
|
assert hass.states.get(state_key) == snapshot
|
||||||
assert state is not None
|
assert entity_registry.async_get(state_key) == snapshot
|
||||||
assert state.state == STATE_ON
|
|
||||||
assert state.attributes["device_class"] == UpdateDeviceClass.FIRMWARE
|
|
||||||
assert state.attributes["installed_version"] == mock_device.firmware_version
|
|
||||||
assert (
|
|
||||||
state.attributes["latest_version"]
|
|
||||||
== FIRMWARE_UPDATE_AVAILABLE.new_firmware_version.split("_")[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
assert entity_registry.async_get(state_key).entity_category == EntityCategory.CONFIG
|
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
PLATFORM,
|
PLATFORM,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user