"""Reboot button.""" from __future__ import annotations from unittest.mock import MagicMock from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN from homeassistant.components.button import SERVICE_PRESS from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import HomeAssistant from tests.helpers import entity_id_for async def test_press_reboots(hass: HomeAssistant, init_integration, mock_client: MagicMock) -> None: entity_id = entity_id_for(hass, "button", "reboot") assert hass.states.get(entity_id).attributes["device_class"] == "restart" await hass.services.async_call( BUTTON_DOMAIN, SERVICE_PRESS, {ATTR_ENTITY_ID: entity_id}, blocking=True ) mock_client.reboot.assert_awaited_once_with()