mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Minor improvement of entity platform tests (#128158)
* Minor improvement of entity platform tests * Fix snapshot
This commit is contained in:
parent
00f7bdbfaa
commit
9ff35d5a5a
37
tests/helpers/snapshots/test_entity_platform.ambr
Normal file
37
tests/helpers/snapshots/test_entity_platform.ambr
Normal file
@ -0,0 +1,37 @@
|
||||
# serializer version: 1
|
||||
# name: test_device_info_called
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': 'heliport',
|
||||
'config_entries': <ANY>,
|
||||
'configuration_url': 'http://192.168.0.100/config',
|
||||
'connections': set({
|
||||
tuple(
|
||||
'mac',
|
||||
'abcd',
|
||||
),
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': <DeviceEntryType.SERVICE: 'service'>,
|
||||
'hw_version': 'test-hw',
|
||||
'id': <ANY>,
|
||||
'identifiers': set({
|
||||
tuple(
|
||||
'hue',
|
||||
'1234',
|
||||
),
|
||||
}),
|
||||
'is_new': False,
|
||||
'labels': set({
|
||||
}),
|
||||
'manufacturer': 'test-manuf',
|
||||
'model': 'test-model',
|
||||
'model_id': None,
|
||||
'name': 'test-name',
|
||||
'name_by_user': None,
|
||||
'primary_config_entry': <ANY>,
|
||||
'serial_number': None,
|
||||
'suggested_area': 'Heliport',
|
||||
'sw_version': 'test-sw',
|
||||
'via_device_id': <ANY>,
|
||||
})
|
||||
# ---
|
@ -8,6 +8,7 @@ from typing import Any
|
||||
from unittest.mock import ANY, AsyncMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -878,9 +879,9 @@ async def test_setup_entry(
|
||||
assert full_name in hass.config.components
|
||||
assert len(hass.states.async_entity_ids()) == 1
|
||||
assert len(entity_registry.entities) == 1
|
||||
assert (
|
||||
entity_registry.entities["test_domain.test1"].config_entry_id == "super-mock-id"
|
||||
)
|
||||
|
||||
entity_registry_entry = entity_registry.entities["test_domain.test1"]
|
||||
assert entity_registry_entry.config_entry_id == "super-mock-id"
|
||||
|
||||
|
||||
async def test_setup_entry_platform_not_ready(
|
||||
@ -1131,7 +1132,9 @@ async def test_add_entity_with_invalid_id(
|
||||
|
||||
|
||||
async def test_device_info_called(
|
||||
hass: HomeAssistant, device_registry: dr.DeviceRegistry
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test device info is forwarded correctly."""
|
||||
config_entry = MockConfigEntry(entry_id="super-mock-id")
|
||||
@ -1185,18 +1188,9 @@ async def test_device_info_called(
|
||||
assert len(hass.states.async_entity_ids()) == 2
|
||||
|
||||
device = device_registry.async_get_device(identifiers={("hue", "1234")})
|
||||
assert device is not None
|
||||
assert device.identifiers == {("hue", "1234")}
|
||||
assert device.configuration_url == "http://192.168.0.100/config"
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "abcd")}
|
||||
assert device.entry_type is dr.DeviceEntryType.SERVICE
|
||||
assert device.manufacturer == "test-manuf"
|
||||
assert device.model == "test-model"
|
||||
assert device.name == "test-name"
|
||||
assert device == snapshot
|
||||
assert device.config_entries == {config_entry.entry_id}
|
||||
assert device.primary_config_entry == config_entry.entry_id
|
||||
assert device.suggested_area == "Heliport"
|
||||
assert device.sw_version == "test-sw"
|
||||
assert device.hw_version == "test-hw"
|
||||
assert device.via_device_id == via.id
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user