core/tests/components/yale/test_button.py

24 lines
1008 B
Python

"""The button tests for the yale platform."""
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from .mocks import _create_yale_api_with_devices, _mock_lock_from_fixture
async def test_wake_lock(hass: HomeAssistant) -> None:
"""Test creation of a lock and wake it."""
lock_one = await _mock_lock_from_fixture(
hass, "get_lock.online_with_doorsense.json"
)
_, api_instance, _ = await _create_yale_api_with_devices(hass, [lock_one])
entity_id = "button.online_with_doorsense_name_wake"
binary_sensor_online_with_doorsense_name = hass.states.get(entity_id)
assert binary_sensor_online_with_doorsense_name is not None
api_instance.async_status_async.reset_mock()
await hass.services.async_call(
BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: entity_id}, blocking=True
)
api_instance.async_status_async.assert_called_once()