From 385630f9b4ea844c727a867e817c8b93f1a6e63b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 6 Apr 2023 18:51:02 +0200 Subject: [PATCH] Fix flaky test in vesync (#90921) * Fix flaky test in vesync * Move sorting to the test --- .../vesync/snapshots/test_diagnostics.ambr | 46 +++++++++---------- tests/components/vesync/test_diagnostics.py | 3 ++ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/tests/components/vesync/snapshots/test_diagnostics.ambr b/tests/components/vesync/snapshots/test_diagnostics.ambr index 33378d7ccde..2c12f9bc5f6 100644 --- a/tests/components/vesync/snapshots/test_diagnostics.ambr +++ b/tests/components/vesync/snapshots/test_diagnostics.ambr @@ -209,6 +209,29 @@ }), 'unit_of_measurement': None, }), + dict({ + 'device_class': None, + 'disabled': False, + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.fan_air_quality', + 'icon': None, + 'name': None, + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Fan Air Quality', + 'state': dict({ + 'attributes': dict({ + 'friendly_name': 'Fan Air Quality', + }), + 'entity_id': 'sensor.fan_air_quality', + 'last_changed': str, + 'last_updated': str, + 'state': 'unavailable', + }), + 'unit_of_measurement': None, + }), dict({ 'device_class': None, 'disabled': False, @@ -234,29 +257,6 @@ }), 'unit_of_measurement': '%', }), - dict({ - 'device_class': None, - 'disabled': False, - 'disabled_by': None, - 'domain': 'sensor', - 'entity_category': None, - 'entity_id': 'sensor.fan_air_quality', - 'icon': None, - 'name': None, - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Fan Air Quality', - 'state': dict({ - 'attributes': dict({ - 'friendly_name': 'Fan Air Quality', - }), - 'entity_id': 'sensor.fan_air_quality', - 'last_changed': str, - 'last_updated': str, - 'state': 'unavailable', - }), - 'unit_of_measurement': None, - }), ]), 'name': 'Fan', 'name_by_user': None, diff --git a/tests/components/vesync/test_diagnostics.py b/tests/components/vesync/test_diagnostics.py index eb802bb41b8..62365189064 100644 --- a/tests/components/vesync/test_diagnostics.py +++ b/tests/components/vesync/test_diagnostics.py @@ -85,6 +85,9 @@ async def test_async_get_device_diagnostics__single_fan( diag = await get_diagnostics_for_device(hass, hass_client, config_entry, device) assert isinstance(diag, dict) + diag["home_assistant"]["entities"] = sorted( + diag["home_assistant"]["entities"], key=lambda ent: ent["entity_id"] + ) assert diag == snapshot( matcher=path_type( {