mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 12:30:31 +00:00
Update airgradient device sw_version when changed (#126902)
This commit is contained in:
committed by
GitHub
parent
ffa6b5fcb2
commit
a3ec4db9cc
@@ -1,7 +1,9 @@
|
||||
"""Tests for the AirGradient integration."""
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.airgradient.const import DOMAIN
|
||||
@@ -10,7 +12,7 @@ from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
|
||||
async def test_device_info(
|
||||
@@ -27,3 +29,28 @@ async def test_device_info(
|
||||
)
|
||||
assert device_entry is not None
|
||||
assert device_entry == snapshot
|
||||
|
||||
|
||||
async def test_new_firmware_version(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test device registry integration."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
device_entry = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, mock_config_entry.unique_id)}
|
||||
)
|
||||
assert device_entry is not None
|
||||
assert device_entry.sw_version == "3.1.1"
|
||||
mock_airgradient_client.get_current_measures.return_value.firmware_version = "3.1.2"
|
||||
freezer.tick(timedelta(minutes=1))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
device_entry = device_registry.async_get_device(
|
||||
identifiers={(DOMAIN, mock_config_entry.unique_id)}
|
||||
)
|
||||
assert device_entry is not None
|
||||
assert device_entry.sw_version == "3.1.2"
|
||||
|
||||
Reference in New Issue
Block a user