mirror of
https://github.com/home-assistant/core.git
synced 2026-04-02 00:20:30 +01:00
75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
"""The tests for SleepIQ binary sensor platform."""
|
|
|
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
|
from homeassistant.const import ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import entity_registry as er
|
|
|
|
from .conftest import BED_ID, BED_NAME, BED_NAME_LOWER, setup_platform
|
|
|
|
|
|
async def test_button_calibrate(
|
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_asyncsleepiq
|
|
) -> None:
|
|
"""Test the SleepIQ calibrate button."""
|
|
await setup_platform(hass, BUTTON_DOMAIN)
|
|
|
|
state = hass.states.get(
|
|
f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_calibrate"
|
|
)
|
|
assert (
|
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
|
== f"{BED_NAME} SleepNumber {BED_NAME} Calibrate"
|
|
)
|
|
|
|
entity = entity_registry.async_get(
|
|
f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_calibrate"
|
|
)
|
|
assert entity
|
|
assert entity.unique_id == f"{BED_ID}-calibrate"
|
|
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
"press",
|
|
{
|
|
ATTR_ENTITY_ID: f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_calibrate"
|
|
},
|
|
blocking=True,
|
|
)
|
|
await hass.async_block_till_done()
|
|
|
|
mock_asyncsleepiq.beds[BED_ID].calibrate.assert_called_once()
|
|
|
|
|
|
async def test_button_stop_pump(
|
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_asyncsleepiq
|
|
) -> None:
|
|
"""Test the SleepIQ stop pump button."""
|
|
await setup_platform(hass, BUTTON_DOMAIN)
|
|
|
|
state = hass.states.get(
|
|
f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_stop_pump"
|
|
)
|
|
assert (
|
|
state.attributes.get(ATTR_FRIENDLY_NAME)
|
|
== f"{BED_NAME} SleepNumber {BED_NAME} Stop Pump"
|
|
)
|
|
|
|
entity = entity_registry.async_get(
|
|
f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_stop_pump"
|
|
)
|
|
assert entity
|
|
assert entity.unique_id == f"{BED_ID}-stop-pump"
|
|
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
"press",
|
|
{
|
|
ATTR_ENTITY_ID: f"button.{BED_NAME_LOWER}_sleepnumber_{BED_NAME_LOWER}_stop_pump"
|
|
},
|
|
blocking=True,
|
|
)
|
|
await hass.async_block_till_done()
|
|
|
|
mock_asyncsleepiq.beds[BED_ID].stop_pump.assert_called_once()
|