mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Move Squeezebox registry tests to test_init (#149050)
This commit is contained in:
parent
7e04a7ec19
commit
b3f049676d
79
tests/components/squeezebox/snapshots/test_init.ambr
Normal file
79
tests/components/squeezebox/snapshots/test_init.ambr
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_device_registry
|
||||||
|
DeviceRegistryEntrySnapshot({
|
||||||
|
'area_id': None,
|
||||||
|
'config_entries': <ANY>,
|
||||||
|
'config_entries_subentries': <ANY>,
|
||||||
|
'configuration_url': None,
|
||||||
|
'connections': set({
|
||||||
|
tuple(
|
||||||
|
'mac',
|
||||||
|
'aa:bb:cc:dd:ee:ff',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'entry_type': None,
|
||||||
|
'hw_version': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'identifiers': set({
|
||||||
|
tuple(
|
||||||
|
'squeezebox',
|
||||||
|
'aa:bb:cc:dd:ee:ff',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'is_new': False,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'manufacturer': 'Ralph Irving & Adrian Smith',
|
||||||
|
'model': 'SqueezeLite',
|
||||||
|
'model_id': None,
|
||||||
|
'name': 'Test Player',
|
||||||
|
'name_by_user': None,
|
||||||
|
'primary_config_entry': <ANY>,
|
||||||
|
'serial_number': None,
|
||||||
|
'suggested_area': None,
|
||||||
|
'sw_version': '',
|
||||||
|
'via_device_id': <ANY>,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_device_registry_server_merged
|
||||||
|
DeviceRegistryEntrySnapshot({
|
||||||
|
'area_id': None,
|
||||||
|
'config_entries': <ANY>,
|
||||||
|
'config_entries_subentries': <ANY>,
|
||||||
|
'configuration_url': None,
|
||||||
|
'connections': set({
|
||||||
|
tuple(
|
||||||
|
'mac',
|
||||||
|
'ff:ee:dd:cc:bb:aa',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'disabled_by': None,
|
||||||
|
'entry_type': <DeviceEntryType.SERVICE: 'service'>,
|
||||||
|
'hw_version': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'identifiers': set({
|
||||||
|
tuple(
|
||||||
|
'squeezebox',
|
||||||
|
'12345678-1234-1234-1234-123456789012',
|
||||||
|
),
|
||||||
|
tuple(
|
||||||
|
'squeezebox',
|
||||||
|
'ff:ee:dd:cc:bb:aa',
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
'is_new': False,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'manufacturer': 'https://lyrion.org/ / Ralph Irving & Adrian Smith',
|
||||||
|
'model': 'Lyrion Music Server/SqueezeLite',
|
||||||
|
'model_id': 'LMS',
|
||||||
|
'name': '1.2.3.4',
|
||||||
|
'name_by_user': None,
|
||||||
|
'primary_config_entry': <ANY>,
|
||||||
|
'serial_number': None,
|
||||||
|
'suggested_area': None,
|
||||||
|
'sw_version': '',
|
||||||
|
'via_device_id': <ANY>,
|
||||||
|
})
|
||||||
|
# ---
|
@ -1,82 +1,4 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_device_registry
|
|
||||||
DeviceRegistryEntrySnapshot({
|
|
||||||
'area_id': None,
|
|
||||||
'config_entries': <ANY>,
|
|
||||||
'config_entries_subentries': <ANY>,
|
|
||||||
'configuration_url': None,
|
|
||||||
'connections': set({
|
|
||||||
tuple(
|
|
||||||
'mac',
|
|
||||||
'aa:bb:cc:dd:ee:ff',
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
'disabled_by': None,
|
|
||||||
'entry_type': None,
|
|
||||||
'hw_version': None,
|
|
||||||
'id': <ANY>,
|
|
||||||
'identifiers': set({
|
|
||||||
tuple(
|
|
||||||
'squeezebox',
|
|
||||||
'aa:bb:cc:dd:ee:ff',
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
'is_new': False,
|
|
||||||
'labels': set({
|
|
||||||
}),
|
|
||||||
'manufacturer': 'Ralph Irving & Adrian Smith',
|
|
||||||
'model': 'SqueezeLite',
|
|
||||||
'model_id': None,
|
|
||||||
'name': 'Test Player',
|
|
||||||
'name_by_user': None,
|
|
||||||
'primary_config_entry': <ANY>,
|
|
||||||
'serial_number': None,
|
|
||||||
'suggested_area': None,
|
|
||||||
'sw_version': '',
|
|
||||||
'via_device_id': <ANY>,
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_device_registry_server_merged
|
|
||||||
DeviceRegistryEntrySnapshot({
|
|
||||||
'area_id': None,
|
|
||||||
'config_entries': <ANY>,
|
|
||||||
'config_entries_subentries': <ANY>,
|
|
||||||
'configuration_url': None,
|
|
||||||
'connections': set({
|
|
||||||
tuple(
|
|
||||||
'mac',
|
|
||||||
'ff:ee:dd:cc:bb:aa',
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
'disabled_by': None,
|
|
||||||
'entry_type': <DeviceEntryType.SERVICE: 'service'>,
|
|
||||||
'hw_version': None,
|
|
||||||
'id': <ANY>,
|
|
||||||
'identifiers': set({
|
|
||||||
tuple(
|
|
||||||
'squeezebox',
|
|
||||||
'12345678-1234-1234-1234-123456789012',
|
|
||||||
),
|
|
||||||
tuple(
|
|
||||||
'squeezebox',
|
|
||||||
'ff:ee:dd:cc:bb:aa',
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
'is_new': False,
|
|
||||||
'labels': set({
|
|
||||||
}),
|
|
||||||
'manufacturer': 'https://lyrion.org/ / Ralph Irving & Adrian Smith',
|
|
||||||
'model': 'Lyrion Music Server/SqueezeLite',
|
|
||||||
'model_id': 'LMS',
|
|
||||||
'name': '1.2.3.4',
|
|
||||||
'name_by_user': None,
|
|
||||||
'primary_config_entry': <ANY>,
|
|
||||||
'serial_number': None,
|
|
||||||
'suggested_area': None,
|
|
||||||
'sw_version': '',
|
|
||||||
'via_device_id': <ANY>,
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_entity_registry[media_player.test_player-entry]
|
# name: test_entity_registry[media_player.test_player-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
"""Test squeezebox initialization."""
|
"""Test squeezebox initialization."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.components.squeezebox.const import DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.device_registry import DeviceRegistry
|
||||||
|
|
||||||
|
from .conftest import TEST_MAC
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
@ -82,3 +88,27 @@ async def test_init_missing_uuid(
|
|||||||
mock_async_query.assert_called_once_with(
|
mock_async_query.assert_called_once_with(
|
||||||
"serverstatus", "-", "-", "prefs:libraryname"
|
"serverstatus", "-", "-", "prefs:libraryname"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_device_registry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
device_registry: DeviceRegistry,
|
||||||
|
configured_player: MagicMock,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
|
"""Test squeezebox device registered in the device registry."""
|
||||||
|
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_MAC[0])})
|
||||||
|
assert reg_device is not None
|
||||||
|
assert reg_device == snapshot
|
||||||
|
|
||||||
|
|
||||||
|
async def test_device_registry_server_merged(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
device_registry: DeviceRegistry,
|
||||||
|
configured_players: MagicMock,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
|
"""Test squeezebox device registered in the device registry."""
|
||||||
|
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_MAC[2])})
|
||||||
|
assert reg_device is not None
|
||||||
|
assert reg_device == snapshot
|
||||||
|
@ -68,7 +68,6 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
|
||||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
@ -82,30 +81,6 @@ from .conftest import (
|
|||||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||||
|
|
||||||
|
|
||||||
async def test_device_registry(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
device_registry: DeviceRegistry,
|
|
||||||
configured_player: MagicMock,
|
|
||||||
snapshot: SnapshotAssertion,
|
|
||||||
) -> None:
|
|
||||||
"""Test squeezebox device registered in the device registry."""
|
|
||||||
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_MAC[0])})
|
|
||||||
assert reg_device is not None
|
|
||||||
assert reg_device == snapshot
|
|
||||||
|
|
||||||
|
|
||||||
async def test_device_registry_server_merged(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
device_registry: DeviceRegistry,
|
|
||||||
configured_players: MagicMock,
|
|
||||||
snapshot: SnapshotAssertion,
|
|
||||||
) -> None:
|
|
||||||
"""Test squeezebox device registered in the device registry."""
|
|
||||||
reg_device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_MAC[2])})
|
|
||||||
assert reg_device is not None
|
|
||||||
assert reg_device == snapshot
|
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(
|
async def test_entity_registry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_registry: EntityRegistry,
|
entity_registry: EntityRegistry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user