hass-core/tests/components/opengarage/test_button.py
Joshua Krall 53717523e5
Add button platform to Opengarage (#103569)
* Add button entity to reboot OpenGarage device

* Addressing code review comments

* Another code-review fix

* Update homeassistant/components/opengarage/button.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-01-04 07:37:24 +01:00

33 lines
1 KiB
Python

"""Test the OpenGarage Browser buttons."""
from unittest.mock import MagicMock
import homeassistant.components.button as button
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import MockConfigEntry
async def test_buttons(
hass: HomeAssistant,
mock_opengarage: MagicMock,
init_integration: MockConfigEntry,
entity_registry: er.EntityRegistry,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test standard OpenGarage buttons."""
entry = entity_registry.async_get("button.abcdef_restart")
assert entry
assert entry.unique_id == "12345_restart"
await hass.services.async_call(
button.DOMAIN,
button.SERVICE_PRESS,
{ATTR_ENTITY_ID: "button.abcdef_restart"},
blocking=True,
)
assert len(mock_opengarage.reboot.mock_calls) == 1
assert entry.device_id
device_entry = device_registry.async_get(entry.device_id)
assert device_entry