mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 23:41:48 -05:00
Improve Tuya event tests (#156259)
This commit is contained in:
@@ -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': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'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': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
'state': '2023-11-01T12:14:15.000+00:00',
|
||||
})
|
||||
# ---
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user