mirror of
https://github.com/home-assistant/core.git
synced 2026-09-10 15:41:22 +01:00
Convert OpenGarage sw_version to string for device registry (#173546)
This commit is contained in:
@@ -52,5 +52,5 @@ class OpenGarageEntity(CoordinatorEntity[OpenGarageDataUpdateCoordinator]):
|
||||
manufacturer="Open Garage",
|
||||
name=self.coordinator.data["name"],
|
||||
suggested_area="Garage",
|
||||
sw_version=self.coordinator.data["fwv"],
|
||||
sw_version=str(self.coordinator.data["fwv"]),
|
||||
)
|
||||
|
||||
@@ -40,7 +40,7 @@ def mock_opengarage() -> Generator[MagicMock]:
|
||||
client.update_state.return_value = {
|
||||
"name": "abcdef",
|
||||
"mac": "aa:bb:cc:dd:ee:ff",
|
||||
"fwv": "1.2.0",
|
||||
"fwv": 120,
|
||||
}
|
||||
yield client
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""Test the OpenGarage Browser buttons."""
|
||||
|
||||
import logging
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import button
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -32,3 +35,24 @@ async def test_buttons(
|
||||
assert entry.device_id
|
||||
device_entry = device_registry.async_get(entry.device_id)
|
||||
assert device_entry
|
||||
|
||||
|
||||
async def test_device_info_sw_version_is_string(
|
||||
hass: HomeAssistant,
|
||||
mock_opengarage: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test that sw_version is a string even when API returns int."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
with caplog.at_level(logging.WARNING, logger="homeassistant.helpers.frame"):
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device_entry = device_registry.async_get_device(
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
)
|
||||
assert device_entry
|
||||
assert device_entry.sw_version == "120"
|
||||
assert "non-string value" not in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user