mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Add diagnostics support to Syncthru (#142776)
This commit is contained in:
parent
6feb9d4b4e
commit
ebe71a1a38
18
homeassistant/components/syncthru/diagnostics.py
Normal file
18
homeassistant/components/syncthru/diagnostics.py
Normal file
@ -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()
|
193
tests/components/syncthru/snapshots/test_diagnostics.ambr
Normal file
193
tests/components/syncthru/snapshots/test_diagnostics.ambr
Normal file
@ -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,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
29
tests/components/syncthru/test_diagnostics.py
Normal file
29
tests/components/syncthru/test_diagnostics.py
Normal file
@ -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
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user