Add device info to canary camera and sensors (#40053)

* add device info to canary sensors

* Update test_sensor.py

* Update sensor.py

* Update sensor.py

* Update test_sensor.py

* Create const.py

* Update sensor.py

* Update test_sensor.py

* Update sensor.py

* Update test_sensor.py

* Update camera.py

* Update camera.py

* Update sensor.py

* Update camera.py

* Update camera.py
This commit is contained in:
Chris Talkington authored and GitHub committed 2020-09-19 10:09:40 -05:00
1 parent 467a001e1f
commit 0c8b530aa2
4 files changed
+49 -5

No files matched your search

+18 -2
View File
@@ -1,5 +1,5 @@
"""The tests for the Canary sensor platform."""
from homeassistant.components.canary import DOMAIN
from homeassistant.components.canary.const import DOMAIN, MANUFACTURER
from homeassistant.components.canary.sensor import (
ATTR_AIR_QUALITY,
STATE_AIR_QUALITY_ABNORMAL,
@@ -20,7 +20,7 @@ from homeassistant.setup import async_setup_component
from . import mock_device, mock_location, mock_reading
from tests.async_mock import patch
from tests.common import mock_registry
from tests.common import mock_device_registry, mock_registry
async def test_sensors_pro(hass, canary) -> None:
@@ -28,6 +28,8 @@ async def test_sensors_pro(hass, canary) -> None:
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
device_registry = mock_device_registry(hass)
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Pro")
instance = canary.return_value
@@ -82,6 +84,12 @@ async def test_sensors_pro(hass, canary) -> None:
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == data[2]
assert state.state == data[1]
device = device_registry.async_get_device({(DOMAIN, "20")}, set())
assert device
assert device.manufacturer == MANUFACTURER
assert device.name == "Dining Room"
assert device.model == "Canary Pro"
async def test_sensors_attributes_pro(hass, canary) -> None:
"""Test the creation and values of the sensors attributes for Canary Pro."""
@@ -142,6 +150,8 @@ async def test_sensors_flex(hass, canary) -> None:
await async_setup_component(hass, "persistent_notification", {})
registry = mock_registry(hass)
device_registry = mock_device_registry(hass)
online_device_at_home = mock_device(20, "Dining Room", True, "Canary Flex")
instance = canary.return_value
@@ -187,3 +197,9 @@ async def test_sensors_flex(hass, canary) -> None:
assert state
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == data[2]
assert state.state == data[1]
device = device_registry.async_get_device({(DOMAIN, "20")}, set())
assert device
assert device.manufacturer == MANUFACTURER
assert device.name == "Dining Room"
assert device.model == "Canary Flex"