mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add LaMetric number tests (#79748)
This commit is contained in:
parent
633ffad443
commit
90d39a414c
@ -662,7 +662,6 @@ omit =
|
||||
homeassistant/components/kwb/sensor.py
|
||||
homeassistant/components/lacrosse/sensor.py
|
||||
homeassistant/components/lametric/notify.py
|
||||
homeassistant/components/lametric/number.py
|
||||
homeassistant/components/lannouncer/notify.py
|
||||
homeassistant/components/lastfm/sensor.py
|
||||
homeassistant/components/launch_library/__init__.py
|
||||
|
73
tests/components/lametric/test_number.py
Normal file
73
tests/components/lametric/test_number.py
Normal file
@ -0,0 +1,73 @@
|
||||
"""Tests for the LaMetric number platform."""
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from homeassistant.components.lametric.const import DOMAIN
|
||||
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, SERVICE_SET_VALUE
|
||||
from homeassistant.components.number.const import (
|
||||
ATTR_MAX,
|
||||
ATTR_MIN,
|
||||
ATTR_STEP,
|
||||
ATTR_VALUE,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_ICON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_volume(
|
||||
hass: HomeAssistant,
|
||||
init_integration: MockConfigEntry,
|
||||
mock_lametric: MagicMock,
|
||||
) -> None:
|
||||
"""Test the LaMetric volume controls."""
|
||||
device_registry = dr.async_get(hass)
|
||||
entity_registry = er.async_get(hass)
|
||||
|
||||
state = hass.states.get("number.frenck_s_lametric_volume")
|
||||
assert state
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "Frenck's LaMetric Volume"
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:volume-high"
|
||||
assert state.attributes.get(ATTR_MAX) == 100
|
||||
assert state.attributes.get(ATTR_MIN) == 0
|
||||
assert state.attributes.get(ATTR_STEP) == 1
|
||||
assert state.state == "100"
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
assert entry.device_id
|
||||
assert entry.entity_category is EntityCategory.CONFIG
|
||||
assert entry.unique_id == "SA110405124500W00BS9-volume"
|
||||
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
assert device
|
||||
assert device.configuration_url is None
|
||||
assert device.connections == {(dr.CONNECTION_NETWORK_MAC, "aa:bb:cc:dd:ee:ff")}
|
||||
assert device.entry_type is None
|
||||
assert device.hw_version is None
|
||||
assert device.identifiers == {(DOMAIN, "SA110405124500W00BS9")}
|
||||
assert device.manufacturer == "LaMetric Inc."
|
||||
assert device.name == "Frenck's LaMetric"
|
||||
assert device.sw_version == "2.2.2"
|
||||
|
||||
await hass.services.async_call(
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{
|
||||
ATTR_ENTITY_ID: "number.frenck_s_lametric_volume",
|
||||
ATTR_VALUE: 42,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_lametric.audio.mock_calls) == 1
|
||||
mock_lametric.audio.assert_called_once_with(volume=42)
|
Loading…
x
Reference in New Issue
Block a user