mirror of
https://github.com/home-assistant/core.git
synced 2025-09-11 07:41:35 +02:00
Add device registry snapshots to Tuya (#150482)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from tuya_sharing import CustomerDevice
|
||||
|
||||
@@ -16,30 +15,40 @@ from . import DEVICE_MOCKS, initialize_entry
|
||||
from tests.common import MockConfigEntry, async_load_json_object_fixture
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mock_device_code", ["ydkt_jevroj5aguwdbs2e"])
|
||||
async def test_unsupported_device(
|
||||
async def test_device_registry(
|
||||
hass: HomeAssistant,
|
||||
mock_manager: ManagerCompat,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_device: CustomerDevice,
|
||||
mock_devices: CustomerDevice,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test unsupported device."""
|
||||
"""Validate device registry snapshots for all devices, including unsupported ones."""
|
||||
|
||||
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||
await initialize_entry(hass, mock_manager, mock_config_entry, mock_devices)
|
||||
|
||||
# Device is registered
|
||||
assert (
|
||||
dr.async_entries_for_config_entry(device_registry, mock_config_entry.entry_id)
|
||||
== snapshot
|
||||
)
|
||||
# No entities registered
|
||||
assert not er.async_entries_for_config_entry(
|
||||
entity_registry, mock_config_entry.entry_id
|
||||
device_registry_entries = dr.async_entries_for_config_entry(
|
||||
device_registry, mock_config_entry.entry_id
|
||||
)
|
||||
|
||||
# Ensure the device registry contains same amount as DEVICE_MOCKS
|
||||
assert len(device_registry_entries) == len(DEVICE_MOCKS)
|
||||
|
||||
for device_registry_entry in device_registry_entries:
|
||||
assert device_registry_entry == snapshot(
|
||||
name=list(device_registry_entry.identifiers)[0][1]
|
||||
)
|
||||
|
||||
# Ensure model is suffixed with "(unsupported)" when no entities are generated
|
||||
assert (" (unsupported)" in device_registry_entry.model) == (
|
||||
not er.async_entries_for_device(
|
||||
entity_registry,
|
||||
device_registry_entry.id,
|
||||
include_disabled_entities=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def test_fixtures_valid(hass: HomeAssistant) -> None:
|
||||
"""Ensure Tuya fixture files are valid."""
|
||||
|
Reference in New Issue
Block a user