From bb7ddddd4cabda922bb65b4aac81f0ac5c90d3a1 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Fri, 6 Oct 2023 20:26:52 +0200 Subject: [PATCH] Use snapshot assertion for lametric diagnostics test (#99164) --- .../lametric/snapshots/test_diagnostics.ambr | 48 +++++++++++++++++++ tests/components/lametric/test_diagnostics.py | 48 +++---------------- 2 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 tests/components/lametric/snapshots/test_diagnostics.ambr diff --git a/tests/components/lametric/snapshots/test_diagnostics.ambr b/tests/components/lametric/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..cadd0e37566 --- /dev/null +++ b/tests/components/lametric/snapshots/test_diagnostics.ambr @@ -0,0 +1,48 @@ +# serializer version: 1 +# name: test_diagnostics + dict({ + 'audio': dict({ + 'volume': 100, + 'volume_limit': dict({ + 'range_max': 100, + 'range_min': 0, + }), + 'volume_range': dict({ + 'range_max': 100, + 'range_min': 0, + }), + }), + 'bluetooth': dict({ + 'active': False, + 'address': 'AA:BB:CC:DD:EE:FF', + 'available': True, + 'discoverable': True, + 'name': '**REDACTED**', + 'pairable': True, + }), + 'device_id': '**REDACTED**', + 'display': dict({ + 'brightness': 100, + 'brightness_mode': 'auto', + 'display_type': 'mixed', + 'height': 8, + 'width': 37, + }), + 'mode': 'auto', + 'model': 'LM 37X8', + 'name': '**REDACTED**', + 'os_version': '2.2.2', + 'serial_number': '**REDACTED**', + 'wifi': dict({ + 'active': True, + 'available': True, + 'encryption': 'WPA', + 'ip': '127.0.0.1', + 'mac': 'AA:BB:CC:DD:EE:FF', + 'mode': 'dhcp', + 'netmask': '255.255.255.0', + 'rssi': 21, + 'ssid': '**REDACTED**', + }), + }) +# --- diff --git a/tests/components/lametric/test_diagnostics.py b/tests/components/lametric/test_diagnostics.py index e36d38b91e3..333985f71a0 100644 --- a/tests/components/lametric/test_diagnostics.py +++ b/tests/components/lametric/test_diagnostics.py @@ -1,6 +1,6 @@ """Tests for the diagnostics data provided by the LaMetric integration.""" +from syrupy import SnapshotAssertion -from homeassistant.components.diagnostics import REDACTED from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry @@ -12,46 +12,10 @@ async def test_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, init_integration: MockConfigEntry, + snapshot: SnapshotAssertion, ) -> None: """Test diagnostics.""" - assert await get_diagnostics_for_config_entry( - hass, hass_client, init_integration - ) == { - "device_id": REDACTED, - "name": REDACTED, - "serial_number": REDACTED, - "os_version": "2.2.2", - "mode": "auto", - "model": "LM 37X8", - "audio": { - "volume": 100, - "volume_range": {"range_min": 0, "range_max": 100}, - "volume_limit": {"range_min": 0, "range_max": 100}, - }, - "bluetooth": { - "available": True, - "name": REDACTED, - "active": False, - "discoverable": True, - "pairable": True, - "address": "AA:BB:CC:DD:EE:FF", - }, - "display": { - "brightness": 100, - "brightness_mode": "auto", - "width": 37, - "height": 8, - "display_type": "mixed", - }, - "wifi": { - "active": True, - "mac": "AA:BB:CC:DD:EE:FF", - "available": True, - "encryption": "WPA", - "ssid": REDACTED, - "ip": "127.0.0.1", - "mode": "dhcp", - "netmask": "255.255.255.0", - "rssi": 21, - }, - } + assert ( + await get_diagnostics_for_config_entry(hass, hass_client, init_integration) + == snapshot + )