diff --git a/tests/components/flexit_bacnet/snapshots/test_climate.ambr b/tests/components/flexit_bacnet/snapshots/test_climate.ambr index 551c5363e98..790c377b1f2 100644 --- a/tests/components/flexit_bacnet/snapshots/test_climate.ambr +++ b/tests/components/flexit_bacnet/snapshots/test_climate.ambr @@ -1,35 +1,5 @@ # serializer version: 1 -# name: test_climate_entity - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'current_temperature': 19.0, - 'friendly_name': 'Device Name', - 'hvac_action': , - 'hvac_modes': list([ - , - , - ]), - 'max_temp': 30, - 'min_temp': 10, - 'preset_mode': 'boost', - 'preset_modes': list([ - 'away', - 'home', - 'boost', - ]), - 'supported_features': , - 'target_temp_step': 0.5, - 'temperature': 22.0, - }), - 'context': , - 'entity_id': 'climate.device_name', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'fan_only', - }) -# --- -# name: test_climate_entity.1 +# name: test_climate_entity[climate.device_name-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ }), @@ -75,3 +45,33 @@ 'unit_of_measurement': None, }) # --- +# name: test_climate_entity[climate.device_name-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'current_temperature': 19.0, + 'friendly_name': 'Device Name', + 'hvac_action': , + 'hvac_modes': list([ + , + , + ]), + 'max_temp': 30, + 'min_temp': 10, + 'preset_mode': 'boost', + 'preset_modes': list([ + 'away', + 'home', + 'boost', + ]), + 'supported_features': , + 'target_temp_step': 0.5, + 'temperature': 22.0, + }), + 'context': , + 'entity_id': 'climate.device_name', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'fan_only', + }) +# --- diff --git a/tests/components/flexit_bacnet/snapshots/test_number.ambr b/tests/components/flexit_bacnet/snapshots/test_number.ambr index 008046bf512..c4fb1e7c434 100644 --- a/tests/components/flexit_bacnet/snapshots/test_number.ambr +++ b/tests/components/flexit_bacnet/snapshots/test_number.ambr @@ -569,563 +569,3 @@ 'state': '60', }) # --- -# name: test_numbers[number.device_name_power_factor-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'away_extract_fan_setpoint', - 'unique_id': '0000-0001-away_extract_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor', - 'last_changed': , - 'last_updated': , - 'state': '30', - }) -# --- -# name: test_numbers[number.device_name_power_factor_10-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_10', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'home_supply_fan_setpoint', - 'unique_id': '0000-0001-home_supply_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_10-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_10', - 'last_changed': , - 'last_updated': , - 'state': '60', - }) -# --- -# name: test_numbers[number.device_name_power_factor_2-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_2', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'away_supply_fan_setpoint', - 'unique_id': '0000-0001-away_supply_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_2-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_2', - 'last_changed': , - 'last_updated': , - 'state': '40', - }) -# --- -# name: test_numbers[number.device_name_power_factor_3-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_3', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'cooker_hood_extract_fan_setpoint', - 'unique_id': '0000-0001-cooker_hood_extract_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_3-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_3', - 'last_changed': , - 'last_updated': , - 'state': '90', - }) -# --- -# name: test_numbers[number.device_name_power_factor_4-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_4', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'cooker_hood_supply_fan_setpoint', - 'unique_id': '0000-0001-cooker_hood_supply_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_4-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_4', - 'last_changed': , - 'last_updated': , - 'state': '100', - }) -# --- -# name: test_numbers[number.device_name_power_factor_5-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_5', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'fireplace_extract_fan_setpoint', - 'unique_id': '0000-0001-fireplace_extract_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_5-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_5', - 'last_changed': , - 'last_updated': , - 'state': '10', - }) -# --- -# name: test_numbers[number.device_name_power_factor_6-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_6', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'fireplace_supply_fan_setpoint', - 'unique_id': '0000-0001-fireplace_supply_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_6-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_6', - 'last_changed': , - 'last_updated': , - 'state': '20', - }) -# --- -# name: test_numbers[number.device_name_power_factor_7-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_7', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'high_extract_fan_setpoint', - 'unique_id': '0000-0001-high_extract_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_7-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_7', - 'last_changed': , - 'last_updated': , - 'state': '70', - }) -# --- -# name: test_numbers[number.device_name_power_factor_8-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_8', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'high_supply_fan_setpoint', - 'unique_id': '0000-0001-high_supply_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_8-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_8', - 'last_changed': , - 'last_updated': , - 'state': '80', - }) -# --- -# name: test_numbers[number.device_name_power_factor_9-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': dict({ - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - }), - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'number', - 'entity_category': None, - 'entity_id': 'number.device_name_power_factor_9', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': , - 'original_icon': None, - 'original_name': 'Power factor', - 'platform': 'flexit_bacnet', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'home_extract_fan_setpoint', - 'unique_id': '0000-0001-home_extract_fan_setpoint', - 'unit_of_measurement': '%', - }) -# --- -# name: test_numbers[number.device_name_power_factor_9-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'device_class': 'power_factor', - 'friendly_name': 'Device Name Power factor', - 'max': 100, - 'min': 0, - 'mode': , - 'step': 1, - 'unit_of_measurement': '%', - }), - 'context': , - 'entity_id': 'number.device_name_power_factor_9', - 'last_changed': , - 'last_updated': , - 'state': '50', - }) -# --- diff --git a/tests/components/flexit_bacnet/test_binary_sensor.py b/tests/components/flexit_bacnet/test_binary_sensor.py index 649eebaec2c..96efefc45ec 100644 --- a/tests/components/flexit_bacnet/test_binary_sensor.py +++ b/tests/components/flexit_bacnet/test_binary_sensor.py @@ -8,7 +8,7 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.flexit_bacnet import setup_with_selected_platforms @@ -24,13 +24,4 @@ async def test_binary_sensors( await setup_with_selected_platforms( hass, mock_config_entry, [Platform.BINARY_SENSOR] ) - entity_entries = er.async_entries_for_config_entry( - entity_registry, mock_config_entry.entry_id - ) - - assert entity_entries - for entity_entry in entity_entries: - assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry") - assert hass.states.get(entity_entry.entity_id) == snapshot( - name=f"{entity_entry.entity_id}-state" - ) + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) diff --git a/tests/components/flexit_bacnet/test_climate.py b/tests/components/flexit_bacnet/test_climate.py index 6c88e6e69d2..7f5a20499ce 100644 --- a/tests/components/flexit_bacnet/test_climate.py +++ b/tests/components/flexit_bacnet/test_climate.py @@ -8,11 +8,9 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant import homeassistant.helpers.entity_registry as er -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.flexit_bacnet import setup_with_selected_platforms -ENTITY_CLIMATE = "climate.device_name" - async def test_climate_entity( hass: HomeAssistant, @@ -24,5 +22,4 @@ async def test_climate_entity( """Test the initial parameters.""" await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE]) - assert hass.states.get(ENTITY_CLIMATE) == snapshot - assert entity_registry.async_get(ENTITY_CLIMATE) == snapshot + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) diff --git a/tests/components/flexit_bacnet/test_number.py b/tests/components/flexit_bacnet/test_number.py index 2aa3c9abcff..921977d0d63 100644 --- a/tests/components/flexit_bacnet/test_number.py +++ b/tests/components/flexit_bacnet/test_number.py @@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.flexit_bacnet import setup_with_selected_platforms ENTITY_ID = "number.device_name_fireplace_supply_fan_setpoint" @@ -29,15 +29,8 @@ async def test_numbers( """Test number states are correctly collected from library.""" await setup_with_selected_platforms(hass, mock_config_entry, [Platform.NUMBER]) - entity_entries = er.async_entries_for_config_entry( - entity_registry, mock_config_entry.entry_id - ) - assert entity_entries - for entity_entry in entity_entries: - assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry") - assert (state := hass.states.get(entity_entry.entity_id)) - assert state == snapshot(name=f"{entity_entry.entity_id}-state") + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) async def test_numbers_implementation( diff --git a/tests/components/flexit_bacnet/test_sensor.py b/tests/components/flexit_bacnet/test_sensor.py index 460f2cf5728..566d3d318f1 100644 --- a/tests/components/flexit_bacnet/test_sensor.py +++ b/tests/components/flexit_bacnet/test_sensor.py @@ -8,7 +8,7 @@ from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.flexit_bacnet import setup_with_selected_platforms @@ -22,13 +22,5 @@ async def test_sensors( """Test sensor states are correctly collected from library.""" await setup_with_selected_platforms(hass, mock_config_entry, [Platform.SENSOR]) - entity_entries = er.async_entries_for_config_entry( - entity_registry, mock_config_entry.entry_id - ) - assert entity_entries - for entity_entry in entity_entries: - assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry") - assert hass.states.get(entity_entry.entity_id) == snapshot( - name=f"{entity_entry.entity_id}-state" - ) + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) diff --git a/tests/components/flexit_bacnet/test_switch.py b/tests/components/flexit_bacnet/test_switch.py index 19c7dfc804e..00ca1997f77 100644 --- a/tests/components/flexit_bacnet/test_switch.py +++ b/tests/components/flexit_bacnet/test_switch.py @@ -16,7 +16,7 @@ from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_registry as er -from tests.common import MockConfigEntry +from tests.common import MockConfigEntry, snapshot_platform from tests.components.flexit_bacnet import setup_with_selected_platforms ENTITY_ID = "switch.device_name_electric_heater" @@ -32,15 +32,8 @@ async def test_switches( """Test switch states are correctly collected from library.""" await setup_with_selected_platforms(hass, mock_config_entry, [Platform.SWITCH]) - entity_entries = er.async_entries_for_config_entry( - entity_registry, mock_config_entry.entry_id - ) - assert entity_entries - for entity_entry in entity_entries: - assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry") - assert (state := hass.states.get(entity_entry.entity_id)) - assert state == snapshot(name=f"{entity_entry.entity_id}-state") + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) async def test_switches_implementation(