From a9d2ddc2e6e023067dff9553bf994b1a5e6391de Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Sun, 17 May 2026 16:16:15 +0000 Subject: [PATCH 1/3] Add tests for Overkiz scene platform Add tests covering the scene entity setup and activation using real fixture data from the python-overkiz-api test suite. --- .../overkiz/fixtures/scenarios/cozytouch.json | 46 +++++++ .../fixtures/scenarios/tahoma_switch.json | 26 ++++ .../overkiz/snapshots/test_scene.ambr | 101 +++++++++++++++ tests/components/overkiz/test_scene.py | 122 ++++++++++++++++++ 4 files changed, 295 insertions(+) create mode 100644 tests/components/overkiz/fixtures/scenarios/cozytouch.json create mode 100644 tests/components/overkiz/fixtures/scenarios/tahoma_switch.json create mode 100644 tests/components/overkiz/snapshots/test_scene.ambr create mode 100644 tests/components/overkiz/test_scene.py diff --git a/tests/components/overkiz/fixtures/scenarios/cozytouch.json b/tests/components/overkiz/fixtures/scenarios/cozytouch.json new file mode 100644 index 0000000000000..64d42ad5deed8 --- /dev/null +++ b/tests/components/overkiz/fixtures/scenarios/cozytouch.json @@ -0,0 +1,46 @@ +[ + { + "creationTime": 1763489130000, + "lastUpdateTime": 1763489130000, + "label": "Label 1", + "metadata": "a56b34aa-2f6f-4e24-b73a-c2ed23f0ac91", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "io://1234-5678-1234/13880042", + "commands": [ + { + "type": 1, + "name": "setHeatingLevel", + "parameters": ["eco"] + } + ] + } + ], + "oid": "0a0589bb-9471-4667-a2a9-4602beb2a2e8" + }, + { + "creationTime": 1763214463000, + "lastUpdateTime": 1763214463000, + "label": "Label 2", + "metadata": "f6206578-b730-4f66-b322-e8d0a5625407", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "io://1234-5678-1234/15581081", + "commands": [ + { + "type": 1, + "name": "setHeatingLevel", + "parameters": ["comfort"] + } + ] + } + ], + "oid": "50d39fc3-9368-49c9-bcbf-c74f3ce1678a" + } +] diff --git a/tests/components/overkiz/fixtures/scenarios/tahoma_switch.json b/tests/components/overkiz/fixtures/scenarios/tahoma_switch.json new file mode 100644 index 0000000000000..bece51a7c100f --- /dev/null +++ b/tests/components/overkiz/fixtures/scenarios/tahoma_switch.json @@ -0,0 +1,26 @@ +[ + { + "creationTime": 1766929020000, + "lastUpdateTime": 1766929020000, + "label": "I'm arriving", + "metadata": "{\"tahoma\":{\"version\":1,\"icon\":\"at_home\",\"template\":\"arriving\"}}", + "shortcut": false, + "notificationTypeMask": 16, + "notificationCondition": "ON_ERROR", + "notificationText": "Your scene I'm arriving could not be played correctly due to an error in one of your products.", + "notificationTitle": "[$[setupLabel]] : Impossible to play the scene I'm arriving", + "actions": [ + { + "deviceURL": "rts://1234-5678-1234/16756006", + "commands": [ + { + "type": 1, + "name": "open", + "parameters": [1] + } + ] + } + ], + "oid": "d1b689e1-4087-473d-b726-d3b24770856f" + } +] diff --git a/tests/components/overkiz/snapshots/test_scene.ambr b/tests/components/overkiz/snapshots/test_scene.ambr new file mode 100644 index 0000000000000..7b72f6a7481c3 --- /dev/null +++ b/tests/components/overkiz/snapshots/test_scene.ambr @@ -0,0 +1,101 @@ +# serializer version: 1 +# name: test_scene_entities_snapshot[scene.label_1-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.label_1', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Label 1', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Label 1', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '0a0589bb-9471-4667-a2a9-4602beb2a2e8', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scene.label_1-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Label 1', + }), + 'context': , + 'entity_id': 'scene.label_1', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scene.label_2-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.label_2', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Label 2', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Label 2', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '50d39fc3-9368-49c9-bcbf-c74f3ce1678a', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scene.label_2-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Label 2', + }), + 'context': , + 'entity_id': 'scene.label_2', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- diff --git a/tests/components/overkiz/test_scene.py b/tests/components/overkiz/test_scene.py new file mode 100644 index 0000000000000..5fb9ca6a83062 --- /dev/null +++ b/tests/components/overkiz/test_scene.py @@ -0,0 +1,122 @@ +"""Tests for the Overkiz scene platform.""" + +from collections.abc import Generator +from unittest.mock import AsyncMock, patch + +import humps +from pyoverkiz.models import Scenario +import pytest +from syrupy.assertion import SnapshotAssertion + +from homeassistant.components.overkiz.const import DOMAIN +from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN +from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON, Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from .conftest import MockOverkizClient, SetupOverkizIntegration + +from tests.common import load_json_array_fixture, snapshot_platform + + +def load_scenarios_fixture(fixture: str) -> list[Scenario]: + """Load scenario fixture and return Scenario objects.""" + data = load_json_array_fixture(fixture, DOMAIN) + return [Scenario(**humps.decamelize(s)) for s in data] + + +TAHOMA_SWITCH_SCENARIOS = load_scenarios_fixture("scenarios/tahoma_switch.json") +COZYTOUCH_SCENARIOS = load_scenarios_fixture("scenarios/cozytouch.json") + + +@pytest.fixture(autouse=True) +def fixture_platforms() -> Generator[None]: + """Limit platforms to scene only.""" + with patch("homeassistant.components.overkiz.PLATFORMS", [Platform.SCENE]): + yield + + +async def test_scene_entities_snapshot( + hass: HomeAssistant, + setup_overkiz_integration: SetupOverkizIntegration, + entity_registry: er.EntityRegistry, + mock_client: MockOverkizClient, + snapshot: SnapshotAssertion, +) -> None: + """Test scene entities via snapshot.""" + mock_client.get_scenarios = AsyncMock(return_value=COZYTOUCH_SCENARIOS) + + config_entry = await setup_overkiz_integration() + + await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id) + + +async def test_scene_activate( + hass: HomeAssistant, + setup_overkiz_integration: SetupOverkizIntegration, + mock_client: MockOverkizClient, +) -> None: + """Test activating a scene calls execute_scenario with the correct OID.""" + mock_client.get_scenarios = AsyncMock(return_value=TAHOMA_SWITCH_SCENARIOS) + mock_client.execute_scenario = AsyncMock(return_value="exec-1") + + await setup_overkiz_integration() + + await hass.services.async_call( + SCENE_DOMAIN, + SERVICE_TURN_ON, + {ATTR_ENTITY_ID: "scene.i_m_arriving"}, + blocking=True, + ) + + mock_client.execute_scenario.assert_awaited_once_with( + "d1b689e1-4087-473d-b726-d3b24770856f" + ) + + +async def test_scene_activate_multiple( + hass: HomeAssistant, + setup_overkiz_integration: SetupOverkizIntegration, + mock_client: MockOverkizClient, +) -> None: + """Test activating different scenes uses the correct OID for each.""" + mock_client.get_scenarios = AsyncMock(return_value=COZYTOUCH_SCENARIOS) + mock_client.execute_scenario = AsyncMock(return_value="exec-1") + + await setup_overkiz_integration() + + await hass.services.async_call( + SCENE_DOMAIN, + SERVICE_TURN_ON, + {ATTR_ENTITY_ID: "scene.label_1"}, + blocking=True, + ) + + mock_client.execute_scenario.assert_awaited_once_with( + "0a0589bb-9471-4667-a2a9-4602beb2a2e8" + ) + + mock_client.execute_scenario.reset_mock() + + await hass.services.async_call( + SCENE_DOMAIN, + SERVICE_TURN_ON, + {ATTR_ENTITY_ID: "scene.label_2"}, + blocking=True, + ) + + mock_client.execute_scenario.assert_awaited_once_with( + "50d39fc3-9368-49c9-bcbf-c74f3ce1678a" + ) + + +async def test_no_scenes_when_empty( + hass: HomeAssistant, + setup_overkiz_integration: SetupOverkizIntegration, + mock_client: MockOverkizClient, +) -> None: + """Test no scene entities are created when there are no scenarios.""" + await setup_overkiz_integration() + + states = hass.states.async_entity_ids(SCENE_DOMAIN) + assert len(states) == 0 From 3de5825cd124cb77d31771228969589f6f02aec6 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Sun, 17 May 2026 16:26:36 +0000 Subject: [PATCH 2/3] Add all scenario fixtures to scene snapshot test Parametrize the snapshot test across all four real fixtures from python-overkiz-api: cozytouch, tahoma_box_v1, tahoma_classic_v2, and tahoma_switch. --- .../fixtures/scenarios/tahoma_box_v1.json | 75 +++++ .../fixtures/scenarios/tahoma_classic_v2.json | 94 ++++++ .../overkiz/snapshots/test_scene.ambr | 308 +++++++++++++++++- tests/components/overkiz/test_scene.py | 24 +- 4 files changed, 489 insertions(+), 12 deletions(-) create mode 100644 tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json create mode 100644 tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json diff --git a/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json b/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json new file mode 100644 index 0000000000000..0d4d79531c433 --- /dev/null +++ b/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json @@ -0,0 +1,75 @@ +[ + { + "creationTime": 1474268697000, + "lastUpdateTime": 1689334259000, + "label": "** **", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "io://1234-5678-1234/11442201", + "commands": [ + { + "type": 1, + "name": "setClosureAndLinearSpeed", + "parameters": [73, "lowspeed"] + } + ] + }, + { + "deviceURL": "io://1234-5678-1234/9394970", + "commands": [ + { + "type": 1, + "name": "setClosureAndLinearSpeed", + "parameters": [76, "lowspeed"] + } + ] + } + ], + "oid": "08559606-8198-41ad-a816-ad4312e7f041" + }, + { + "creationTime": 1514121653000, + "lastUpdateTime": 1621231501000, + "label": "**ä** **", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "io://1234-5678-1234/7730534", + "commands": [ + { + "type": 1, + "name": "setClosureAndLinearSpeed", + "parameters": [0, "lowspeed"] + } + ] + } + ], + "oid": "1f5ba70c-9913-4d21-ad24-1a92ca10aa2f" + }, + { + "creationTime": 1565356740000, + "lastUpdateTime": 1565356740000, + "label": "** **", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "io://1234-5678-1234/7731450", + "commands": [ + { + "type": 1, + "name": "undeploy", + "parameters": [] + } + ] + } + ], + "oid": "5efd387b-cb87-4d77-afcf-dd9c3fd5a1ad" + } +] diff --git a/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json b/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json new file mode 100644 index 0000000000000..cb15b45fba890 --- /dev/null +++ b/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json @@ -0,0 +1,94 @@ +[ + { + "creationTime": 1550508542000, + "lastUpdateTime": 1602072175000, + "label": "** **", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "rts://1234-5678-1234/16765962", + "commands": [ + { + "type": 1, + "name": "my", + "parameters": [] + } + ] + }, + { + "deviceURL": "rts://1234-5678-1234/16755525", + "commands": [ + { + "type": 1, + "name": "my", + "parameters": [] + } + ] + }, + { + "deviceURL": "rts://1234-5678-1234/16737657", + "commands": [ + { + "type": 1, + "name": "my", + "parameters": [] + } + ] + }, + { + "deviceURL": "io://1234-5678-1234/16108086", + "commands": [ + { + "type": 1, + "name": "on", + "parameters": [] + } + ] + } + ], + "oid": "353d8f5d-8854-4b12-9b71-2cf8621e2d0c" + }, + { + "creationTime": 1550508523000, + "lastUpdateTime": 1602072175000, + "label": "** **", + "shortcut": false, + "notificationTypeMask": 0, + "notificationCondition": "NEVER", + "actions": [ + { + "deviceURL": "rts://1234-5678-1234/16765962", + "commands": [ + { + "type": 1, + "name": "open", + "parameters": [] + } + ] + }, + { + "deviceURL": "rts://1234-5678-1234/16755525", + "commands": [ + { + "type": 1, + "name": "open", + "parameters": [] + } + ] + }, + { + "deviceURL": "rts://1234-5678-1234/16737657", + "commands": [ + { + "type": 1, + "name": "open", + "parameters": [] + } + ] + } + ], + "oid": "b6b921ee-a5a8-44cb-a54d-76d1ce9cc899" + } +] diff --git a/tests/components/overkiz/snapshots/test_scene.ambr b/tests/components/overkiz/snapshots/test_scene.ambr index 7b72f6a7481c3..ee5facad24fcd 100644 --- a/tests/components/overkiz/snapshots/test_scene.ambr +++ b/tests/components/overkiz/snapshots/test_scene.ambr @@ -1,5 +1,5 @@ # serializer version: 1 -# name: test_scene_entities_snapshot[scene.label_1-entry] +# name: test_scene_entities_snapshot[scenarios/cozytouch.json][scene.label_1-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -36,7 +36,7 @@ 'unit_of_measurement': None, }) # --- -# name: test_scene_entities_snapshot[scene.label_1-state] +# name: test_scene_entities_snapshot[scenarios/cozytouch.json][scene.label_1-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Label 1', @@ -49,7 +49,7 @@ 'state': 'unknown', }) # --- -# name: test_scene_entities_snapshot[scene.label_2-entry] +# name: test_scene_entities_snapshot[scenarios/cozytouch.json][scene.label_2-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ None, @@ -86,7 +86,7 @@ 'unit_of_measurement': None, }) # --- -# name: test_scene_entities_snapshot[scene.label_2-state] +# name: test_scene_entities_snapshot[scenarios/cozytouch.json][scene.label_2-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'friendly_name': 'Label 2', @@ -99,3 +99,303 @@ 'state': 'unknown', }) # --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.a-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.a', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': '**ä** **', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': '**ä** **', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '1f5ba70c-9913-4d21-ad24-1a92ca10aa2f', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.a-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': '**ä** **', + }), + 'context': , + 'entity_id': 'scene.a', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.unknown', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': '** **', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': '** **', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '08559606-8198-41ad-a816-ad4312e7f041', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': '** **', + }), + 'context': , + 'entity_id': 'scene.unknown', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown_2-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.unknown_2', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': '** **', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': '** **', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '5efd387b-cb87-4d77-afcf-dd9c3fd5a1ad', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown_2-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': '** **', + }), + 'context': , + 'entity_id': 'scene.unknown_2', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.unknown', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': '** **', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': '** **', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '353d8f5d-8854-4b12-9b71-2cf8621e2d0c', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': '** **', + }), + 'context': , + 'entity_id': 'scene.unknown', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown_2-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.unknown_2', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': '** **', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': '** **', + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'b6b921ee-a5a8-44cb-a54d-76d1ce9cc899', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown_2-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': '** **', + }), + 'context': , + 'entity_id': 'scene.unknown_2', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_switch.json][scene.i_m_arriving-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'scene', + 'entity_category': None, + 'entity_id': 'scene.i_m_arriving', + 'has_entity_name': False, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': "I'm arriving", + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': "I'm arriving", + 'platform': 'overkiz', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'd1b689e1-4087-473d-b726-d3b24770856f', + 'unit_of_measurement': None, + }) +# --- +# name: test_scene_entities_snapshot[scenarios/tahoma_switch.json][scene.i_m_arriving-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': "I'm arriving", + }), + 'context': , + 'entity_id': 'scene.i_m_arriving', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- diff --git a/tests/components/overkiz/test_scene.py b/tests/components/overkiz/test_scene.py index 5fb9ca6a83062..ec05a55af634a 100644 --- a/tests/components/overkiz/test_scene.py +++ b/tests/components/overkiz/test_scene.py @@ -18,6 +18,13 @@ from tests.common import load_json_array_fixture, snapshot_platform +SCENARIO_FIXTURES = [ + "scenarios/cozytouch.json", + "scenarios/tahoma_box_v1.json", + "scenarios/tahoma_classic_v2.json", + "scenarios/tahoma_switch.json", +] + def load_scenarios_fixture(fixture: str) -> list[Scenario]: """Load scenario fixture and return Scenario objects.""" @@ -25,10 +32,6 @@ def load_scenarios_fixture(fixture: str) -> list[Scenario]: return [Scenario(**humps.decamelize(s)) for s in data] -TAHOMA_SWITCH_SCENARIOS = load_scenarios_fixture("scenarios/tahoma_switch.json") -COZYTOUCH_SCENARIOS = load_scenarios_fixture("scenarios/cozytouch.json") - - @pytest.fixture(autouse=True) def fixture_platforms() -> Generator[None]: """Limit platforms to scene only.""" @@ -36,15 +39,18 @@ def fixture_platforms() -> Generator[None]: yield +@pytest.mark.parametrize("fixture", SCENARIO_FIXTURES) async def test_scene_entities_snapshot( hass: HomeAssistant, setup_overkiz_integration: SetupOverkizIntegration, entity_registry: er.EntityRegistry, mock_client: MockOverkizClient, snapshot: SnapshotAssertion, + fixture: str, ) -> None: - """Test scene entities via snapshot.""" - mock_client.get_scenarios = AsyncMock(return_value=COZYTOUCH_SCENARIOS) + """Test scene entities via snapshot for each fixture.""" + scenarios = load_scenarios_fixture(fixture) + mock_client.get_scenarios = AsyncMock(return_value=scenarios) config_entry = await setup_overkiz_integration() @@ -57,7 +63,8 @@ async def test_scene_activate( mock_client: MockOverkizClient, ) -> None: """Test activating a scene calls execute_scenario with the correct OID.""" - mock_client.get_scenarios = AsyncMock(return_value=TAHOMA_SWITCH_SCENARIOS) + scenarios = load_scenarios_fixture("scenarios/tahoma_switch.json") + mock_client.get_scenarios = AsyncMock(return_value=scenarios) mock_client.execute_scenario = AsyncMock(return_value="exec-1") await setup_overkiz_integration() @@ -80,7 +87,8 @@ async def test_scene_activate_multiple( mock_client: MockOverkizClient, ) -> None: """Test activating different scenes uses the correct OID for each.""" - mock_client.get_scenarios = AsyncMock(return_value=COZYTOUCH_SCENARIOS) + scenarios = load_scenarios_fixture("scenarios/cozytouch.json") + mock_client.get_scenarios = AsyncMock(return_value=scenarios) mock_client.execute_scenario = AsyncMock(return_value="exec-1") await setup_overkiz_integration() From 3e8206d80f4ebe46cedc800fb5ff7438dd49c046 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Sun, 17 May 2026 16:29:50 +0000 Subject: [PATCH 3/3] Remove redundant scenario fixtures Keep only cozytouch (multiple scenarios) and tahoma_switch (single scenario with special characters) since the scene entity has no branching logic based on actions or device types. --- .../fixtures/scenarios/tahoma_box_v1.json | 75 ------ .../fixtures/scenarios/tahoma_classic_v2.json | 94 ------- .../overkiz/snapshots/test_scene.ambr | 250 ------------------ tests/components/overkiz/test_scene.py | 2 - 4 files changed, 421 deletions(-) delete mode 100644 tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json delete mode 100644 tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json diff --git a/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json b/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json deleted file mode 100644 index 0d4d79531c433..0000000000000 --- a/tests/components/overkiz/fixtures/scenarios/tahoma_box_v1.json +++ /dev/null @@ -1,75 +0,0 @@ -[ - { - "creationTime": 1474268697000, - "lastUpdateTime": 1689334259000, - "label": "** **", - "shortcut": false, - "notificationTypeMask": 0, - "notificationCondition": "NEVER", - "actions": [ - { - "deviceURL": "io://1234-5678-1234/11442201", - "commands": [ - { - "type": 1, - "name": "setClosureAndLinearSpeed", - "parameters": [73, "lowspeed"] - } - ] - }, - { - "deviceURL": "io://1234-5678-1234/9394970", - "commands": [ - { - "type": 1, - "name": "setClosureAndLinearSpeed", - "parameters": [76, "lowspeed"] - } - ] - } - ], - "oid": "08559606-8198-41ad-a816-ad4312e7f041" - }, - { - "creationTime": 1514121653000, - "lastUpdateTime": 1621231501000, - "label": "**ä** **", - "shortcut": false, - "notificationTypeMask": 0, - "notificationCondition": "NEVER", - "actions": [ - { - "deviceURL": "io://1234-5678-1234/7730534", - "commands": [ - { - "type": 1, - "name": "setClosureAndLinearSpeed", - "parameters": [0, "lowspeed"] - } - ] - } - ], - "oid": "1f5ba70c-9913-4d21-ad24-1a92ca10aa2f" - }, - { - "creationTime": 1565356740000, - "lastUpdateTime": 1565356740000, - "label": "** **", - "shortcut": false, - "notificationTypeMask": 0, - "notificationCondition": "NEVER", - "actions": [ - { - "deviceURL": "io://1234-5678-1234/7731450", - "commands": [ - { - "type": 1, - "name": "undeploy", - "parameters": [] - } - ] - } - ], - "oid": "5efd387b-cb87-4d77-afcf-dd9c3fd5a1ad" - } -] diff --git a/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json b/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json deleted file mode 100644 index cb15b45fba890..0000000000000 --- a/tests/components/overkiz/fixtures/scenarios/tahoma_classic_v2.json +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "creationTime": 1550508542000, - "lastUpdateTime": 1602072175000, - "label": "** **", - "shortcut": false, - "notificationTypeMask": 0, - "notificationCondition": "NEVER", - "actions": [ - { - "deviceURL": "rts://1234-5678-1234/16765962", - "commands": [ - { - "type": 1, - "name": "my", - "parameters": [] - } - ] - }, - { - "deviceURL": "rts://1234-5678-1234/16755525", - "commands": [ - { - "type": 1, - "name": "my", - "parameters": [] - } - ] - }, - { - "deviceURL": "rts://1234-5678-1234/16737657", - "commands": [ - { - "type": 1, - "name": "my", - "parameters": [] - } - ] - }, - { - "deviceURL": "io://1234-5678-1234/16108086", - "commands": [ - { - "type": 1, - "name": "on", - "parameters": [] - } - ] - } - ], - "oid": "353d8f5d-8854-4b12-9b71-2cf8621e2d0c" - }, - { - "creationTime": 1550508523000, - "lastUpdateTime": 1602072175000, - "label": "** **", - "shortcut": false, - "notificationTypeMask": 0, - "notificationCondition": "NEVER", - "actions": [ - { - "deviceURL": "rts://1234-5678-1234/16765962", - "commands": [ - { - "type": 1, - "name": "open", - "parameters": [] - } - ] - }, - { - "deviceURL": "rts://1234-5678-1234/16755525", - "commands": [ - { - "type": 1, - "name": "open", - "parameters": [] - } - ] - }, - { - "deviceURL": "rts://1234-5678-1234/16737657", - "commands": [ - { - "type": 1, - "name": "open", - "parameters": [] - } - ] - } - ], - "oid": "b6b921ee-a5a8-44cb-a54d-76d1ce9cc899" - } -] diff --git a/tests/components/overkiz/snapshots/test_scene.ambr b/tests/components/overkiz/snapshots/test_scene.ambr index ee5facad24fcd..93209f71145f7 100644 --- a/tests/components/overkiz/snapshots/test_scene.ambr +++ b/tests/components/overkiz/snapshots/test_scene.ambr @@ -99,256 +99,6 @@ 'state': 'unknown', }) # --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.a-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'scene', - 'entity_category': None, - 'entity_id': 'scene.a', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': '**ä** **', - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': '**ä** **', - 'platform': 'overkiz', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '1f5ba70c-9913-4d21-ad24-1a92ca10aa2f', - 'unit_of_measurement': None, - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.a-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': '**ä** **', - }), - 'context': , - 'entity_id': 'scene.a', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'scene', - 'entity_category': None, - 'entity_id': 'scene.unknown', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': '** **', - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': '** **', - 'platform': 'overkiz', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '08559606-8198-41ad-a816-ad4312e7f041', - 'unit_of_measurement': None, - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': '** **', - }), - 'context': , - 'entity_id': 'scene.unknown', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown_2-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'scene', - 'entity_category': None, - 'entity_id': 'scene.unknown_2', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': '** **', - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': '** **', - 'platform': 'overkiz', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '5efd387b-cb87-4d77-afcf-dd9c3fd5a1ad', - 'unit_of_measurement': None, - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_box_v1.json][scene.unknown_2-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': '** **', - }), - 'context': , - 'entity_id': 'scene.unknown_2', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'scene', - 'entity_category': None, - 'entity_id': 'scene.unknown', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': '** **', - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': '** **', - 'platform': 'overkiz', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': '353d8f5d-8854-4b12-9b71-2cf8621e2d0c', - 'unit_of_measurement': None, - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': '** **', - }), - 'context': , - 'entity_id': 'scene.unknown', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown_2-entry] - EntityRegistryEntrySnapshot({ - 'aliases': list([ - None, - ]), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'config_subentry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'scene', - 'entity_category': None, - 'entity_id': 'scene.unknown_2', - 'has_entity_name': False, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'object_id_base': '** **', - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': '** **', - 'platform': 'overkiz', - 'previous_unique_id': None, - 'suggested_object_id': None, - 'supported_features': 0, - 'translation_key': None, - 'unique_id': 'b6b921ee-a5a8-44cb-a54d-76d1ce9cc899', - 'unit_of_measurement': None, - }) -# --- -# name: test_scene_entities_snapshot[scenarios/tahoma_classic_v2.json][scene.unknown_2-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': '** **', - }), - 'context': , - 'entity_id': 'scene.unknown_2', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- # name: test_scene_entities_snapshot[scenarios/tahoma_switch.json][scene.i_m_arriving-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/overkiz/test_scene.py b/tests/components/overkiz/test_scene.py index ec05a55af634a..443d01b8b3d97 100644 --- a/tests/components/overkiz/test_scene.py +++ b/tests/components/overkiz/test_scene.py @@ -20,8 +20,6 @@ SCENARIO_FIXTURES = [ "scenarios/cozytouch.json", - "scenarios/tahoma_box_v1.json", - "scenarios/tahoma_classic_v2.json", "scenarios/tahoma_switch.json", ]