diff --git a/tests/components/tuya/snapshots/test_event.ambr b/tests/components/tuya/snapshots/test_event.ambr index ce7c1cf67deb..035bd88d72c4 100644 --- a/tests/components/tuya/snapshots/test_event.ambr +++ b/tests/components/tuya/snapshots/test_event.ambr @@ -43,7 +43,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'button', - 'event_type': None, + 'event_type': 'click', 'event_types': list([ 'click', 'press', @@ -55,7 +55,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'unknown', + 'state': '2023-11-01T12:14:15.000+00:00', }) # --- # name: test_platform_setup_and_discovery[event.bathroom_smart_switch_button_2-entry] @@ -102,7 +102,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'button', - 'event_type': None, + 'event_type': 'click', 'event_types': list([ 'click', 'press', @@ -114,7 +114,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'unknown', + 'state': '2023-11-01T12:14:15.000+00:00', }) # --- # name: test_platform_setup_and_discovery[event.bouton_tempo_exterieur_button_1-entry] @@ -162,7 +162,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'device_class': 'button', - 'event_type': None, + 'event_type': 'press', 'event_types': list([ 'click', 'double_click', @@ -175,6 +175,6 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': 'unknown', + 'state': '2023-11-01T12:14:15.000+00:00', }) # --- diff --git a/tests/components/tuya/test_event.py b/tests/components/tuya/test_event.py index ec69b58781e3..e871f61d5c26 100644 --- a/tests/components/tuya/test_event.py +++ b/tests/components/tuya/test_event.py @@ -4,6 +4,7 @@ from __future__ import annotations from unittest.mock import patch +import pytest from syrupy.assertion import SnapshotAssertion from tuya_sharing import CustomerDevice, Manager @@ -11,21 +12,29 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from . import initialize_entry +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)