Files
core/tests/components/tuya/test_event.py
T

41 lines
1.3 KiB
Python

"""Test Tuya event platform."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from syrupy.assertion import SnapshotAssertion
from tuya_sharing import CustomerDevice, Manager
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import MockDeviceListener, initialize_entry
from tests.common import MockConfigEntry, snapshot_platform
@pytest.mark.freeze_time("2023-11-01 13:14:15+01:00")
@patch("homeassistant.components.tuya.PLATFORMS", [Platform.EVENT])
async def test_platform_setup_and_discovery(
hass: HomeAssistant,
mock_manager: Manager,
mock_config_entry: MockConfigEntry,
mock_devices: list[CustomerDevice],
mock_listener: MockDeviceListener,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test platform setup and discovery."""
await initialize_entry(hass, mock_manager, mock_config_entry, mock_devices)
for mock_device in mock_devices:
# Simulate an initial device update to generate events
await mock_listener.async_send_device_update(
hass, mock_device, mock_device.status
)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)