diff --git a/tests/components/sfr_box/const.py b/tests/components/sfr_box/const.py index c3ed56e32a7..44a2ce4a575 100644 --- a/tests/components/sfr_box/const.py +++ b/tests/components/sfr_box/const.py @@ -1,5 +1,4 @@ """Constants for SFR Box tests.""" -from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.button import ButtonDeviceClass from homeassistant.components.sensor import ATTR_OPTIONS, ATTR_STATE_CLASS from homeassistant.components.sfr_box.const import DOMAIN @@ -12,7 +11,6 @@ from homeassistant.const import ( ATTR_STATE, ATTR_SW_VERSION, ATTR_UNIT_OF_MEASUREMENT, - STATE_ON, STATE_UNKNOWN, Platform, ) @@ -33,14 +31,6 @@ EXPECTED_ENTITIES = { ATTR_NAME: "SFR Box", ATTR_SW_VERSION: "NB6VAC-MAIN-R4.0.44k", }, - Platform.BINARY_SENSOR: [ - { - ATTR_DEVICE_CLASS: BinarySensorDeviceClass.CONNECTIVITY, - ATTR_ENTITY_ID: "binary_sensor.sfr_box_dsl_status", - ATTR_STATE: STATE_ON, - ATTR_UNIQUE_ID: "e4:5d:51:00:11:22_dsl_status", - }, - ], Platform.BUTTON: [ { ATTR_DEVICE_CLASS: ButtonDeviceClass.RESTART, diff --git a/tests/components/sfr_box/snapshots/test_binary_sensor.ambr b/tests/components/sfr_box/snapshots/test_binary_sensor.ambr new file mode 100644 index 00000000000..c3442c08e24 --- /dev/null +++ b/tests/components/sfr_box/snapshots/test_binary_sensor.ambr @@ -0,0 +1,75 @@ +# serializer version: 1 +# name: test_binary_sensors + list([ + DeviceRegistryEntrySnapshot({ + 'area_id': None, + 'config_entries': , + 'configuration_url': 'http://192.168.0.1', + 'connections': set({ + }), + 'disabled_by': None, + 'entry_type': None, + 'hw_version': None, + 'id': , + 'identifiers': set({ + tuple( + 'sfr_box', + 'e4:5d:51:00:11:22', + ), + }), + 'is_new': False, + 'manufacturer': None, + 'model': 'NB6VAC-FXC-r0', + 'name': 'SFR Box', + 'name_by_user': None, + 'suggested_area': None, + 'sw_version': 'NB6VAC-MAIN-R4.0.44k', + 'via_device_id': None, + }), + ]) +# --- +# name: test_binary_sensors.1 + list([ + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.sfr_box_dsl_status', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'DSL status', + 'platform': 'sfr_box', + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'e4:5d:51:00:11:22_dsl_status', + 'unit_of_measurement': None, + }), + ]) +# --- +# name: test_binary_sensors[binary_sensor.sfr_box_dsl_status] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'connectivity', + 'friendly_name': 'SFR Box DSL status', + }), + 'context': , + 'entity_id': 'binary_sensor.sfr_box_dsl_status', + 'last_changed': , + 'last_updated': , + 'state': 'on', + }) +# --- diff --git a/tests/components/sfr_box/test_binary_sensor.py b/tests/components/sfr_box/test_binary_sensor.py index 0aed381cff1..03e0677713b 100644 --- a/tests/components/sfr_box/test_binary_sensor.py +++ b/tests/components/sfr_box/test_binary_sensor.py @@ -1,17 +1,15 @@ -"""Test the SFR Box sensors.""" +"""Test the SFR Box binary sensors.""" from collections.abc import Generator from unittest.mock import patch import pytest +from syrupy.assertion import SnapshotAssertion from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er -from . import check_device_registry, check_entities -from .const import EXPECTED_ENTITIES - pytestmark = pytest.mark.usefixtures("system_get_info", "dsl_get_info") @@ -27,14 +25,21 @@ async def test_binary_sensors( config_entry: ConfigEntry, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, ) -> None: """Test for SFR Box binary sensors.""" await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - check_device_registry(device_registry, EXPECTED_ENTITIES["expected_device"]) + device_entries = dr.async_entries_for_config_entry( + device_registry, config_entry.entry_id + ) + assert device_entries == snapshot - expected_entities = EXPECTED_ENTITIES[Platform.BINARY_SENSOR] - assert len(entity_registry.entities) == len(expected_entities) + entity_entries = er.async_entries_for_config_entry( + entity_registry, config_entry.entry_id + ) + assert entity_entries == snapshot - check_entities(hass, entity_registry, expected_entities) + for entity in entity_entries: + assert hass.states.get(entity.entity_id) == snapshot(name=entity.entity_id)