mirror of
https://github.com/home-assistant/core.git
synced 2026-07-14 18:14:35 +01:00
41c9a5c4e3
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Validate Yardian button behavior."""
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
from syrupy.assertion 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 . import setup_integration
|
|
|
|
from tests.common import MockConfigEntry, snapshot_platform
|
|
|
|
|
|
@patch("homeassistant.components.yardian.PLATFORMS", [Platform.BUTTON])
|
|
async def test_all_entities(
|
|
hass: HomeAssistant,
|
|
snapshot: SnapshotAssertion,
|
|
mock_yardian_client: AsyncMock,
|
|
mock_config_entry: MockConfigEntry,
|
|
entity_registry: er.EntityRegistry,
|
|
) -> None:
|
|
"""Test all button entities."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
|
|
|
|
|
@patch("homeassistant.components.yardian.button.BUTTON_REFRESH_DELAY", 0)
|
|
async def test_stop_all_button(
|
|
hass: HomeAssistant,
|
|
mock_yardian_client: AsyncMock,
|
|
mock_config_entry: MockConfigEntry,
|
|
) -> None:
|
|
"""Test pressing the stop irrigation button."""
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
SERVICE_PRESS,
|
|
{ATTR_ENTITY_ID: "button.yardian_smart_sprinkler_stop_irrigation"},
|
|
blocking=True,
|
|
)
|
|
mock_yardian_client.stop_irrigation.assert_called_once()
|