hass-core/tests/components/tessie/test_button.py
Brett Adams 858fb1fa37
Add snapshot testing to Tessie (#108346)
* Redo Binary Sensors

* Redo Button

* Redo Climate

* Stage unfixed platforms

* Redo Cover

* Redo device tracker

* Redo lock

* Redo Media Player

* Redo Number

* Redo Select

* Redo Sensor

* Redo Switch

* Redo Update

* Fix setup_platform

* Add mixing snapshot

* Fix config flow

* Centralise entity testing

* Update snapshot

* Rename test_entities

* Fix assert_entities
2024-01-27 13:43:55 +01:00

40 lines
1.4 KiB
Python

"""Test the Tessie button platform."""
from unittest.mock import patch
from syrupy import SnapshotAssertion
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .common import assert_entities, setup_platform
async def test_buttons(
hass: HomeAssistant, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry
) -> None:
"""Tests that the button entities are correct."""
entry = await setup_platform(hass, [Platform.BUTTON])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
for entity_id, func in [
("button.test_wake", "wake"),
("button.test_flash_lights", "flash_lights"),
("button.test_honk_horn", "honk"),
("button.test_homelink", "trigger_homelink"),
("button.test_keyless_driving", "enable_keyless_driving"),
("button.test_play_fart", "boombox"),
]:
with patch(
f"homeassistant.components.tessie.button.{func}",
) as mock_press:
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_press.assert_called_once()