mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Use constants for device registry checks (#58514)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
91b07cce20
commit
19eba5a3a0
@ -12,7 +12,13 @@ from homeassistant.components.media_player.const import (
|
||||
MEDIA_TYPE_MUSIC,
|
||||
SERVICE_SELECT_SOURCE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
)
|
||||
|
||||
from .conftest import MOCK_HOST, MOCK_NAME, MOCK_PORT, MOCK_UUID
|
||||
|
||||
@ -32,10 +38,13 @@ async def test_properties(player, state):
|
||||
"""Test standard properties."""
|
||||
assert player.unique_id == f"{MOCK_UUID}-1"
|
||||
assert player.device_info == {
|
||||
"name": f"Arcam FMJ ({MOCK_HOST})",
|
||||
"identifiers": {("arcam_fmj", MOCK_UUID), ("arcam_fmj", MOCK_HOST, MOCK_PORT)},
|
||||
"model": "Arcam FMJ AVR",
|
||||
"manufacturer": "Arcam",
|
||||
ATTR_NAME: f"Arcam FMJ ({MOCK_HOST})",
|
||||
ATTR_IDENTIFIERS: {
|
||||
("arcam_fmj", MOCK_UUID),
|
||||
("arcam_fmj", MOCK_HOST, MOCK_PORT),
|
||||
},
|
||||
ATTR_MODEL: "Arcam FMJ AVR",
|
||||
ATTR_MANUFACTURER: "Arcam",
|
||||
}
|
||||
assert not player.should_poll
|
||||
|
||||
|
@ -3,6 +3,12 @@
|
||||
from google_nest_sdm.device import Device
|
||||
|
||||
from homeassistant.components.nest.device_info import NestDeviceInfo
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
)
|
||||
|
||||
|
||||
def test_device_custom_name():
|
||||
@ -25,10 +31,10 @@ def test_device_custom_name():
|
||||
assert device_info.device_model == "Doorbell"
|
||||
assert device_info.device_brand == "Google Nest"
|
||||
assert device_info.device_info == {
|
||||
"identifiers": {("nest", "some-device-id")},
|
||||
"name": "My Doorbell",
|
||||
"manufacturer": "Google Nest",
|
||||
"model": "Doorbell",
|
||||
ATTR_IDENTIFIERS: {("nest", "some-device-id")},
|
||||
ATTR_NAME: "My Doorbell",
|
||||
ATTR_MANUFACTURER: "Google Nest",
|
||||
ATTR_MODEL: "Doorbell",
|
||||
}
|
||||
|
||||
|
||||
@ -50,10 +56,10 @@ def test_device_name_room():
|
||||
assert device_info.device_model == "Doorbell"
|
||||
assert device_info.device_brand == "Google Nest"
|
||||
assert device_info.device_info == {
|
||||
"identifiers": {("nest", "some-device-id")},
|
||||
"name": "Some Room",
|
||||
"manufacturer": "Google Nest",
|
||||
"model": "Doorbell",
|
||||
ATTR_IDENTIFIERS: {("nest", "some-device-id")},
|
||||
ATTR_NAME: "Some Room",
|
||||
ATTR_MANUFACTURER: "Google Nest",
|
||||
ATTR_MODEL: "Doorbell",
|
||||
}
|
||||
|
||||
|
||||
@ -69,10 +75,10 @@ def test_device_no_name():
|
||||
assert device_info.device_model == "Doorbell"
|
||||
assert device_info.device_brand == "Google Nest"
|
||||
assert device_info.device_info == {
|
||||
"identifiers": {("nest", "some-device-id")},
|
||||
"name": "Doorbell",
|
||||
"manufacturer": "Google Nest",
|
||||
"model": "Doorbell",
|
||||
ATTR_IDENTIFIERS: {("nest", "some-device-id")},
|
||||
ATTR_NAME: "Doorbell",
|
||||
ATTR_MANUFACTURER: "Google Nest",
|
||||
ATTR_MODEL: "Doorbell",
|
||||
}
|
||||
|
||||
|
||||
@ -96,8 +102,8 @@ def test_device_invalid_type():
|
||||
assert device_info.device_model is None
|
||||
assert device_info.device_brand == "Google Nest"
|
||||
assert device_info.device_info == {
|
||||
"identifiers": {("nest", "some-device-id")},
|
||||
"name": "My Doorbell",
|
||||
"manufacturer": "Google Nest",
|
||||
"model": None,
|
||||
ATTR_IDENTIFIERS: {("nest", "some-device-id")},
|
||||
ATTR_NAME: "My Doorbell",
|
||||
ATTR_MANUFACTURER: "Google Nest",
|
||||
ATTR_MODEL: None,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user