From 3a978fc244efc4f384a1f167fe0e03a22176e473 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 24 Jan 2022 08:46:22 -0700 Subject: [PATCH] Clean up post-merge review comments (#64842) * Clean up post-merge diagnostics PRs * Trigger Build * Linting --- .../components/flunearyou/diagnostics.py | 16 +- .../components/notion/diagnostics.py | 4 +- .../components/flunearyou/test_diagnostics.py | 114 +++++----- tests/components/notion/test_diagnostics.py | 194 +++++++++--------- 4 files changed, 159 insertions(+), 169 deletions(-) diff --git a/homeassistant/components/flunearyou/diagnostics.py b/homeassistant/components/flunearyou/diagnostics.py index 666ffb66c67..1f7812a7403 100644 --- a/homeassistant/components/flunearyou/diagnostics.py +++ b/homeassistant/components/flunearyou/diagnostics.py @@ -23,14 +23,10 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinators: dict[str, DataUpdateCoordinator] = hass.data[DOMAIN][entry.entry_id] - return { - "data": { - CATEGORY_CDC_REPORT: async_redact_data( - coordinators[CATEGORY_CDC_REPORT].data, TO_REDACT - ), - CATEGORY_USER_REPORT: [ - async_redact_data(report, TO_REDACT) - for report in coordinators[CATEGORY_USER_REPORT].data - ], + return async_redact_data( + { + CATEGORY_CDC_REPORT: coordinators[CATEGORY_CDC_REPORT].data, + CATEGORY_USER_REPORT: coordinators[CATEGORY_USER_REPORT].data, }, - } + TO_REDACT, + ) diff --git a/homeassistant/components/notion/diagnostics.py b/homeassistant/components/notion/diagnostics.py index 051ffde412b..9e1d6d3b7a4 100644 --- a/homeassistant/components/notion/diagnostics.py +++ b/homeassistant/components/notion/diagnostics.py @@ -27,6 +27,4 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id] - return { - "data": async_redact_data(coordinator.data, TO_REDACT), - } + return async_redact_data(coordinator.data, TO_REDACT) diff --git a/tests/components/flunearyou/test_diagnostics.py b/tests/components/flunearyou/test_diagnostics.py index a01d78d5de2..1775f088a1f 100644 --- a/tests/components/flunearyou/test_diagnostics.py +++ b/tests/components/flunearyou/test_diagnostics.py @@ -7,63 +7,61 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry async def test_entry_diagnostics(hass, config_entry, hass_client, setup_flunearyou): """Test config entry diagnostics.""" assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == { - "data": { - "cdc_report": { - "level": "Low", - "level2": "None", - "week_date": "2020-05-16", - "name": "Washington State", - "fill": {"color": "#00B7B6", "opacity": 0.7}, - }, - "user_report": [ - { - "id": 1, - "city": "Chester(72934)", - "place_id": "49377", - "zip": "72934", - "contained_by": "610", - "latitude": REDACTED, - "longitude": REDACTED, - "none": 1, - "symptoms": 0, - "flu": 0, - "lepto": 0, - "dengue": 0, - "chick": 0, - "icon": "1", - }, - { - "id": 2, - "city": "Los Angeles(90046)", - "place_id": "23818", - "zip": "90046", - "contained_by": "204", - "latitude": REDACTED, - "longitude": REDACTED, - "none": 2, - "symptoms": 0, - "flu": 0, - "lepto": 0, - "dengue": 0, - "chick": 0, - "icon": "1", - }, - { - "id": 3, - "city": "Corvallis(97330)", - "place_id": "21462", - "zip": "97330", - "contained_by": "239", - "latitude": REDACTED, - "longitude": REDACTED, - "none": 3, - "symptoms": 0, - "flu": 0, - "lepto": 0, - "dengue": 0, - "chick": 0, - "icon": "1", - }, - ], + "cdc_report": { + "level": "Low", + "level2": "None", + "week_date": "2020-05-16", + "name": "Washington State", + "fill": {"color": "#00B7B6", "opacity": 0.7}, }, + "user_report": [ + { + "id": 1, + "city": "Chester(72934)", + "place_id": "49377", + "zip": "72934", + "contained_by": "610", + "latitude": REDACTED, + "longitude": REDACTED, + "none": 1, + "symptoms": 0, + "flu": 0, + "lepto": 0, + "dengue": 0, + "chick": 0, + "icon": "1", + }, + { + "id": 2, + "city": "Los Angeles(90046)", + "place_id": "23818", + "zip": "90046", + "contained_by": "204", + "latitude": REDACTED, + "longitude": REDACTED, + "none": 2, + "symptoms": 0, + "flu": 0, + "lepto": 0, + "dengue": 0, + "chick": 0, + "icon": "1", + }, + { + "id": 3, + "city": "Corvallis(97330)", + "place_id": "21462", + "zip": "97330", + "contained_by": "239", + "latitude": REDACTED, + "longitude": REDACTED, + "none": 3, + "symptoms": 0, + "flu": 0, + "lepto": 0, + "dengue": 0, + "chick": 0, + "icon": "1", + }, + ], } diff --git a/tests/components/notion/test_diagnostics.py b/tests/components/notion/test_diagnostics.py index 5e6498d3cbc..39d2777462f 100644 --- a/tests/components/notion/test_diagnostics.py +++ b/tests/components/notion/test_diagnostics.py @@ -7,107 +7,105 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry async def test_entry_diagnostics(hass, config_entry, hass_client, setup_notion): """Test config entry diagnostics.""" assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == { - "data": { - "bridges": { - "12345": { - "id": 12345, - "name": None, - "mode": "home", - "hardware_id": "0x1234567890abcdef", - "hardware_revision": 4, - "firmware_version": { - "wifi": "0.121.0", - "wifi_app": "3.3.0", - "silabs": "1.0.1", - }, - "missing_at": None, - "created_at": "2019-04-30T01:43:50.497Z", - "updated_at": "2019-04-30T01:44:43.749Z", - "system_id": 12345, - "firmware": { - "wifi": "0.121.0", - "wifi_app": "3.3.0", - "silabs": "1.0.1", - }, - "links": {"system": 12345}, - } - }, - "sensors": { - "123456": { - "id": 123456, - "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - "user": {"id": 12345, "email": REDACTED}, - "bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"}, - "last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - "name": "Bathroom Sensor", - "location_id": 123456, - "system_id": 12345, - "hardware_id": "0x1234567890abcdef", - "firmware_version": "1.1.2", - "hardware_revision": 5, - "device_key": REDACTED, - "encryption_key": True, - "installed_at": "2019-04-30T01:57:34.443Z", - "calibrated_at": "2019-04-30T01:57:35.651Z", - "last_reported_at": "2019-04-30T02:20:04.821Z", - "missing_at": None, - "updated_at": "2019-04-30T01:57:36.129Z", - "created_at": "2019-04-30T01:56:45.932Z", - "signal_strength": 5, - "links": {"location": 123456}, - "lqi": 0, - "rssi": -46, - "surface_type": None, + "bridges": { + "12345": { + "id": 12345, + "name": None, + "mode": "home", + "hardware_id": "0x1234567890abcdef", + "hardware_revision": 4, + "firmware_version": { + "wifi": "0.121.0", + "wifi_app": "3.3.0", + "silabs": "1.0.1", }, - "132462": { - "id": 132462, - "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - "user": {"id": 12345, "email": REDACTED}, - "bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"}, - "last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - "name": "Living Room Sensor", - "location_id": 123456, - "system_id": 12345, - "hardware_id": "0x1234567890abcdef", - "firmware_version": "1.1.2", - "hardware_revision": 5, - "device_key": REDACTED, - "encryption_key": True, - "installed_at": "2019-04-30T01:45:56.169Z", - "calibrated_at": "2019-04-30T01:46:06.256Z", - "last_reported_at": "2019-04-30T02:20:04.829Z", - "missing_at": None, - "updated_at": "2019-04-30T01:46:07.717Z", - "created_at": "2019-04-30T01:45:14.148Z", - "signal_strength": 5, - "links": {"location": 123456}, - "lqi": 0, - "rssi": -30, - "surface_type": None, + "missing_at": None, + "created_at": "2019-04-30T01:43:50.497Z", + "updated_at": "2019-04-30T01:44:43.749Z", + "system_id": 12345, + "firmware": { + "wifi": "0.121.0", + "wifi_app": "3.3.0", + "silabs": "1.0.1", }, + "links": {"system": 12345}, + } + }, + "sensors": { + "123456": { + "id": 123456, + "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "user": {"id": 12345, "email": REDACTED}, + "bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"}, + "last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "name": "Bathroom Sensor", + "location_id": 123456, + "system_id": 12345, + "hardware_id": "0x1234567890abcdef", + "firmware_version": "1.1.2", + "hardware_revision": 5, + "device_key": REDACTED, + "encryption_key": True, + "installed_at": "2019-04-30T01:57:34.443Z", + "calibrated_at": "2019-04-30T01:57:35.651Z", + "last_reported_at": "2019-04-30T02:20:04.821Z", + "missing_at": None, + "updated_at": "2019-04-30T01:57:36.129Z", + "created_at": "2019-04-30T01:56:45.932Z", + "signal_strength": 5, + "links": {"location": 123456}, + "lqi": 0, + "rssi": -46, + "surface_type": None, }, - "tasks": { - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": { - "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - "task_type": "low_battery", - "sensor_data": [], - "status": { - "insights": { - "primary": { - "from_state": None, - "to_state": "high", - "data_received_at": "2020-11-17T18:40:27.024Z", - "origin": {}, - } - } - }, - "created_at": "2020-11-17T18:40:27.024Z", - "updated_at": "2020-11-17T18:40:27.033Z", - "sensor_id": 525993, - "model_version": "4.1", - "configuration": {}, - "links": {"sensor": 525993}, - } + "132462": { + "id": 132462, + "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "user": {"id": 12345, "email": REDACTED}, + "bridge": {"id": 12345, "hardware_id": "0x1234567890abcdef"}, + "last_bridge_hardware_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "name": "Living Room Sensor", + "location_id": 123456, + "system_id": 12345, + "hardware_id": "0x1234567890abcdef", + "firmware_version": "1.1.2", + "hardware_revision": 5, + "device_key": REDACTED, + "encryption_key": True, + "installed_at": "2019-04-30T01:45:56.169Z", + "calibrated_at": "2019-04-30T01:46:06.256Z", + "last_reported_at": "2019-04-30T02:20:04.829Z", + "missing_at": None, + "updated_at": "2019-04-30T01:46:07.717Z", + "created_at": "2019-04-30T01:45:14.148Z", + "signal_strength": 5, + "links": {"location": 123456}, + "lqi": 0, + "rssi": -30, + "surface_type": None, }, }, + "tasks": { + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx": { + "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + "task_type": "low_battery", + "sensor_data": [], + "status": { + "insights": { + "primary": { + "from_state": None, + "to_state": "high", + "data_received_at": "2020-11-17T18:40:27.024Z", + "origin": {}, + } + } + }, + "created_at": "2020-11-17T18:40:27.024Z", + "updated_at": "2020-11-17T18:40:27.033Z", + "sensor_id": 525993, + "model_version": "4.1", + "configuration": {}, + "links": {"sensor": 525993}, + } + }, }