1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Use constants for device registry checks (#58514)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet
2021-10-27 11:34:58 +02:00
committed by GitHub
parent 91b07cce20
commit 19eba5a3a0
2 changed files with 36 additions and 21 deletions

View File

@@ -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,
}