diff --git a/homeassistant/components/syncthru/diagnostics.py b/homeassistant/components/syncthru/diagnostics.py new file mode 100644 index 00000000000..5ff860ed41e --- /dev/null +++ b/homeassistant/components/syncthru/diagnostics.py @@ -0,0 +1,18 @@ +"""Diagnostics support for Syncthru.""" + +from __future__ import annotations + +from typing import Any + +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant + +from .const import DOMAIN + + +async def async_get_config_entry_diagnostics( + hass: HomeAssistant, entry: ConfigEntry +) -> dict[str, Any]: + """Return diagnostics for a config entry.""" + + return hass.data[DOMAIN][entry.entry_id].data.raw() diff --git a/tests/components/syncthru/snapshots/test_diagnostics.ambr b/tests/components/syncthru/snapshots/test_diagnostics.ambr new file mode 100644 index 00000000000..9b22561a2d6 --- /dev/null +++ b/tests/components/syncthru/snapshots/test_diagnostics.ambr @@ -0,0 +1,193 @@ +# serializer version: 1 +# name: test_diagnostics + dict({ + 'GXI_A3_SUPPORT': 0, + 'GXI_ACTIVE_ALERT_TOTAL': 2, + 'GXI_ADMIN_WUI_HAS_DEFAULT_PASS': 0, + 'GXI_IMAGING_BLACK_VALID': 1, + 'GXI_IMAGING_COLOR_VALID': 1, + 'GXI_IMAGING_CYAN_VALID': 1, + 'GXI_IMAGING_MAGENTA_VALID': 1, + 'GXI_IMAGING_YELLOW_VALID': 1, + 'GXI_INSTALL_OPTION_MULTIBIN': 0, + 'GXI_INTRAY_MANUALFEEDING_TRAY_SUPPORT': 0, + 'GXI_SUPPORT_COLOR': 1, + 'GXI_SUPPORT_MULTI_PASS': 1, + 'GXI_SUPPORT_PAPER_LEVEL': 0, + 'GXI_SUPPORT_PAPER_SETTING': 1, + 'GXI_SWS_ADMIN_USE_AAA': 0, + 'GXI_SYS_LUI_SUPPORT': 0, + 'GXI_TONER_BLACK_VALID': 1, + 'GXI_TONER_CYAN_VALID': 1, + 'GXI_TONER_MAGENTA_VALID': 1, + 'GXI_TONER_YELLOW_VALID': 1, + 'GXI_TRAY2_MANDATORY_SUPPORT': 0, + 'capability': dict({ + 'hdd': dict({ + 'capa': 40, + 'opt': 2, + }), + 'ram': dict({ + 'capa': 65536, + 'opt': 65536, + }), + 'scanner': dict({ + 'capa': 0, + 'opt': 0, + }), + }), + 'drum_black': dict({ + 'newError': '', + 'opt': 0, + 'remaining': 44, + }), + 'drum_color': dict({ + 'newError': '', + 'opt': 1, + 'remaining': 44, + }), + 'drum_cyan': dict({ + 'newError': '', + 'opt': 0, + 'remaining': 100, + }), + 'drum_magenta': dict({ + 'newError': '', + 'opt': 0, + 'remaining': 100, + }), + 'drum_yellow': dict({ + 'newError': '', + 'opt': 0, + 'remaining': 100, + }), + 'identity': dict({ + 'admin_email': '', + 'admin_name': '', + 'admin_phone': '', + 'customer_support': '', + 'device_name': 'Samsung C430W', + 'host_name': 'SEC84251907C415', + 'ip_addr': '192.168.0.251', + 'ipv6_link_addr': '', + 'location': 'Living room', + 'mac_addr': '84:25:19:07:C4:15', + 'model_name': 'C430W', + 'serial_num': '08HRB8GJ3F019DD', + }), + 'manual': dict({ + 'capa': 0, + 'newError': '', + 'opt': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'mp': dict({ + 'capa': 0, + 'newError': '', + 'opt': 0, + 'paper_level': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'multibin': list([ + 0, + ]), + 'options': dict({ + 'hdd': 0, + 'wlan': 1, + }), + 'outputTray': list([ + list([ + 1, + 50, + '', + ]), + ]), + 'status': dict({ + 'hrDeviceStatus': 3, + 'status1': '', + 'status2': '', + 'status3': '', + 'status4': '', + }), + 'toner_black': dict({ + 'cnt': 1176, + 'newError': 'C1-5110', + 'opt': 1, + 'remaining': 8, + }), + 'toner_cyan': dict({ + 'cnt': 25, + 'newError': '', + 'opt': 1, + 'remaining': 98, + }), + 'toner_magenta': dict({ + 'cnt': 25, + 'newError': '', + 'opt': 1, + 'remaining': 98, + }), + 'toner_yellow': dict({ + 'cnt': 27, + 'newError': '', + 'opt': 1, + 'remaining': 97, + }), + 'tray1': dict({ + 'capa': 150, + 'newError': '', + 'opt': 1, + 'paper_level': 0, + 'paper_size1': 4, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'tray2': dict({ + 'capa': 0, + 'newError': '', + 'opt': 0, + 'paper_level': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'tray3': dict({ + 'capa': 0, + 'newError': '', + 'opt': 0, + 'paper_level': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'tray4': dict({ + 'capa': 0, + 'newError': '', + 'opt': 0, + 'paper_level': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + 'tray5': dict({ + 'capa': 0, + 'newError': '0', + 'opt': 0, + 'paper_level': 0, + 'paper_size1': 0, + 'paper_size2': 0, + 'paper_type1': 2, + 'paper_type2': 0, + }), + }) +# --- diff --git a/tests/components/syncthru/test_diagnostics.py b/tests/components/syncthru/test_diagnostics.py new file mode 100644 index 00000000000..f5988936328 --- /dev/null +++ b/tests/components/syncthru/test_diagnostics.py @@ -0,0 +1,29 @@ +"""Tests for the diagnostics data provided by the Syncthru integration.""" + +from unittest.mock import AsyncMock + +from syrupy import SnapshotAssertion + +from homeassistant.core import HomeAssistant + +from . import setup_integration + +from tests.common import MockConfigEntry +from tests.components.diagnostics import get_diagnostics_for_config_entry +from tests.typing import ClientSessionGenerator + + +async def test_diagnostics( + hass: HomeAssistant, + hass_client: ClientSessionGenerator, + mock_syncthru: AsyncMock, + mock_config_entry: MockConfigEntry, + snapshot: SnapshotAssertion, +) -> None: + """Test diagnostics.""" + await setup_integration(hass, mock_config_entry) + + assert ( + await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry) + == snapshot + )