Add test snapshots to ring switch and siren platforms (#125771)
This commit is contained in:
parent
66f9e06c25
commit
75d3ea34fc
5 changed files with 197 additions and 5 deletions
|
@ -13,9 +13,10 @@ from tests.common import MockConfigEntry
|
|||
|
||||
async def setup_platform(hass: HomeAssistant, platform: Platform) -> None:
|
||||
"""Set up the ring platform and prerequisites."""
|
||||
MockConfigEntry(domain=DOMAIN, data={"username": "foo", "token": {}}).add_to_hass(
|
||||
hass
|
||||
)
|
||||
if not hass.config_entries.async_has_entries(DOMAIN):
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN, data={"username": "foo", "token": {}}
|
||||
).add_to_hass(hass)
|
||||
with patch("homeassistant.components.ring.PLATFORMS", [platform]):
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
|
58
tests/components/ring/snapshots/test_siren.ambr
Normal file
58
tests/components/ring/snapshots/test_siren.ambr
Normal file
|
@ -0,0 +1,58 @@
|
|||
# serializer version: 1
|
||||
# name: test_states[siren.downstairs_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'available_tones': list([
|
||||
'ding',
|
||||
'motion',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'siren',
|
||||
'entity_category': None,
|
||||
'entity_id': 'siren.downstairs_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <SirenEntityFeature: 5>,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '123456-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[siren.downstairs_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'available_tones': list([
|
||||
'ding',
|
||||
'motion',
|
||||
]),
|
||||
'friendly_name': 'Downstairs Siren',
|
||||
'supported_features': <SirenEntityFeature: 5>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'siren.downstairs_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
95
tests/components/ring/snapshots/test_switch.ambr
Normal file
95
tests/components/ring/snapshots/test_switch.ambr
Normal file
|
@ -0,0 +1,95 @@
|
|||
# serializer version: 1
|
||||
# name: test_states[switch.front_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.front_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '765432-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.front_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Front Siren',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.front_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_siren-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.internal_siren',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Siren',
|
||||
'platform': 'ring',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'siren',
|
||||
'unique_id': '345678-siren',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_states[switch.internal_siren-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Ring.com',
|
||||
'friendly_name': 'Internal Siren',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.internal_siren',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
|
@ -1,7 +1,10 @@
|
|||
"""The tests for the Ring button platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import Platform
|
||||
|
@ -9,7 +12,9 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import setup_platform
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_entity_registry(
|
||||
|
@ -24,6 +29,20 @@ async def test_entity_registry(
|
|||
assert entry.unique_id == "123456-siren"
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_sirens_report_correctly(hass: HomeAssistant, mock_ring_client) -> None:
|
||||
"""Tests that the initial state of a device that should be on is correct."""
|
||||
await setup_platform(hass, Platform.SIREN)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
"""The tests for the Ring switch platform."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
import ring_doorbell
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import SOURCE_REAUTH
|
||||
from homeassistant.const import Platform
|
||||
|
@ -9,7 +12,9 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import setup_platform
|
||||
from .common import MockConfigEntry, setup_platform
|
||||
|
||||
from tests.common import snapshot_platform
|
||||
|
||||
|
||||
async def test_entity_registry(
|
||||
|
@ -27,6 +32,20 @@ async def test_entity_registry(
|
|||
assert entry.unique_id == "345678-siren"
|
||||
|
||||
|
||||
async def test_states(
|
||||
hass: HomeAssistant,
|
||||
mock_ring_client: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test states."""
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await setup_platform(hass, Platform.SWITCH)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_siren_off_reports_correctly(
|
||||
hass: HomeAssistant, mock_ring_client
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue