From 39992c2ccc6cb31f4e971f18cfab5835b3880a52 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Wed, 23 Aug 2023 20:20:08 +0200 Subject: [PATCH] Migrate BSB-Lan diagnostics test to snapshot assertion (#98899) Migrate bsblan diagnostics test to snapshot assertion --- .../bsblan/fixtures/diagnostics.json | 75 ------------------ .../bsblan/snapshots/test_diagnostics.ambr | 78 +++++++++++++++++++ tests/components/bsblan/test_diagnostics.py | 10 +-- 3 files changed, 83 insertions(+), 80 deletions(-) delete mode 100644 tests/components/bsblan/fixtures/diagnostics.json create mode 100644 tests/components/bsblan/snapshots/test_diagnostics.ambr diff --git a/tests/components/bsblan/fixtures/diagnostics.json b/tests/components/bsblan/fixtures/diagnostics.json deleted file mode 100644 index bd05aca56d5..00000000000 --- a/tests/components/bsblan/fixtures/diagnostics.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "info": { - "device_identification": { - "name": "Gerte-Identifikation", - "unit": "", - "desc": "", - "value": "RVS21.831F/127", - "dataType": 7 - }, - "controller_family": { - "name": "Device family", - "unit": "", - "desc": "", - "value": "211", - "dataType": 0 - }, - "controller_variant": { - "name": "Device variant", - "unit": "", - "desc": "", - "value": "127", - "dataType": 0 - } - }, - "device": { - "name": "BSB-LAN", - "version": "1.0.38-20200730234859", - "MAC": "00:80:41:19:69:90", - "uptime": 969402857 - }, - "state": { - "hvac_mode": { - "name": "Operating mode", - "unit": "", - "desc": "Komfort", - "value": "heat", - "dataType": 1 - }, - "hvac_mode2": { - "name": "Operating mode", - "unit": "", - "desc": "Reduziert", - "value": "2", - "dataType": 1 - }, - "target_temperature": { - "name": "Room temperature Comfort setpoint", - "unit": "°C", - "desc": "", - "value": "18.5", - "dataType": 0 - }, - "hvac_action": { - "name": "Status heating circuit 1", - "unit": "", - "desc": "Raumtemp\u2019begrenzung", - "value": "122", - "dataType": 1 - }, - "current_temperature": { - "name": "Room temp 1 actual value", - "unit": "°C", - "desc": "", - "value": "18.6", - "dataType": 0 - }, - "room1_thermostat_mode": { - "name": "Raumthermostat 1", - "unit": "", - "desc": "Kein Bedarf", - "value": "0", - "dataType": 1 - } - } -} diff --git a/tests/components/bsblan/snapshots/test_diagnostics.ambr b/tests/components/bsblan/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..2fff33de046 --- /dev/null +++ b/tests/components/bsblan/snapshots/test_diagnostics.ambr @@ -0,0 +1,78 @@ +# serializer version: 1 +# name: test_diagnostics + dict({ + 'device': dict({ + 'MAC': '00:80:41:19:69:90', + 'name': 'BSB-LAN', + 'uptime': 969402857, + 'version': '1.0.38-20200730234859', + }), + 'info': dict({ + 'controller_family': dict({ + 'dataType': 0, + 'desc': '', + 'name': 'Device family', + 'unit': '', + 'value': '211', + }), + 'controller_variant': dict({ + 'dataType': 0, + 'desc': '', + 'name': 'Device variant', + 'unit': '', + 'value': '127', + }), + 'device_identification': dict({ + 'dataType': 7, + 'desc': '', + 'name': 'Gerte-Identifikation', + 'unit': '', + 'value': 'RVS21.831F/127', + }), + }), + 'state': dict({ + 'current_temperature': dict({ + 'dataType': 0, + 'desc': '', + 'name': 'Room temp 1 actual value', + 'unit': '°C', + 'value': '18.6', + }), + 'hvac_action': dict({ + 'dataType': 1, + 'desc': 'Raumtemp’begrenzung', + 'name': 'Status heating circuit 1', + 'unit': '', + 'value': '122', + }), + 'hvac_mode': dict({ + 'dataType': 1, + 'desc': 'Komfort', + 'name': 'Operating mode', + 'unit': '', + 'value': 'heat', + }), + 'hvac_mode2': dict({ + 'dataType': 1, + 'desc': 'Reduziert', + 'name': 'Operating mode', + 'unit': '', + 'value': '2', + }), + 'room1_thermostat_mode': dict({ + 'dataType': 1, + 'desc': 'Kein Bedarf', + 'name': 'Raumthermostat 1', + 'unit': '', + 'value': '0', + }), + 'target_temperature': dict({ + 'dataType': 0, + 'desc': '', + 'name': 'Room temperature Comfort setpoint', + 'unit': '°C', + 'value': '18.5', + }), + }), + }) +# --- diff --git a/tests/components/bsblan/test_diagnostics.py b/tests/components/bsblan/test_diagnostics.py index b2b5d201b93..316296df78a 100644 --- a/tests/components/bsblan/test_diagnostics.py +++ b/tests/components/bsblan/test_diagnostics.py @@ -1,9 +1,10 @@ """Tests for the diagnostics data provided by the BSBLan integration.""" -import json + +from syrupy import SnapshotAssertion from homeassistant.core import HomeAssistant -from tests.common import MockConfigEntry, load_fixture +from tests.common import MockConfigEntry from tests.components.diagnostics import get_diagnostics_for_config_entry from tests.typing import ClientSessionGenerator @@ -12,12 +13,11 @@ async def test_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, init_integration: MockConfigEntry, + snapshot: SnapshotAssertion, ) -> None: """Test diagnostics.""" - diagnostics_fixture = json.loads(load_fixture("bsblan/diagnostics.json")) - assert ( await get_diagnostics_for_config_entry(hass, hass_client, init_integration) - == diagnostics_fixture + == snapshot )