mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add diagnostics platform to Immich integration (#145162)
* add diagnostics platform * also redact host
This commit is contained in:
parent
cb84e55c34
commit
0fc81d6b33
26
homeassistant/components/immich/diagnostics.py
Normal file
26
homeassistant/components/immich/diagnostics.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Diagnostics support for immich."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .coordinator import ImmichConfigEntry
|
||||
|
||||
TO_REDACT = {CONF_API_KEY, CONF_HOST}
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ImmichConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator = entry.runtime_data
|
||||
|
||||
return {
|
||||
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||
"data": asdict(coordinator.data),
|
||||
}
|
@ -39,7 +39,7 @@ rules:
|
||||
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: Service can't be discovered
|
||||
|
66
tests/components/immich/snapshots/test_diagnostics.ambr
Normal file
66
tests/components/immich/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,66 @@
|
||||
# serializer version: 1
|
||||
# name: test_entry_diagnostics
|
||||
dict({
|
||||
'data': dict({
|
||||
'server_about': dict({
|
||||
'build': None,
|
||||
'build_image': None,
|
||||
'build_image_url': None,
|
||||
'build_url': None,
|
||||
'exiftool': None,
|
||||
'ffmpeg': None,
|
||||
'imagemagick': None,
|
||||
'libvips': None,
|
||||
'licensed': False,
|
||||
'nodejs': None,
|
||||
'repository': None,
|
||||
'repository_url': None,
|
||||
'source_commit': None,
|
||||
'source_ref': None,
|
||||
'source_url': None,
|
||||
'version': 'v1.132.3',
|
||||
'version_url': 'some_url',
|
||||
}),
|
||||
'server_storage': dict({
|
||||
'disk_available': '136.3 GiB',
|
||||
'disk_available_raw': 146402975744,
|
||||
'disk_size': '294.2 GiB',
|
||||
'disk_size_raw': 315926315008,
|
||||
'disk_usage_percentage': 48.56,
|
||||
'disk_use': '142.9 GiB',
|
||||
'disk_use_raw': 153400434688,
|
||||
}),
|
||||
'server_usage': dict({
|
||||
'photos': 27038,
|
||||
'usage': 119525451912,
|
||||
'usage_photos': 54291170551,
|
||||
'usage_videos': 65234281361,
|
||||
'videos': 1836,
|
||||
}),
|
||||
}),
|
||||
'entry': dict({
|
||||
'data': dict({
|
||||
'api_key': '**REDACTED**',
|
||||
'host': '**REDACTED**',
|
||||
'port': 80,
|
||||
'ssl': False,
|
||||
'verify_ssl': True,
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'discovery_keys': dict({
|
||||
}),
|
||||
'domain': 'immich',
|
||||
'minor_version': 1,
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'subentries': list([
|
||||
]),
|
||||
'title': 'Someone',
|
||||
'unique_id': 'e7ef5713-9dab-4bd4-b899-715b0ca4379e',
|
||||
'version': 1,
|
||||
}),
|
||||
})
|
||||
# ---
|
33
tests/components/immich/test_diagnostics.py
Normal file
33
tests/components/immich/test_diagnostics.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""Tests for the Immich integration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from syrupy import SnapshotAssertion
|
||||
from syrupy.filters import props
|
||||
|
||||
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_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_immich: Mock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
result = await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_config_entry
|
||||
)
|
||||
|
||||
assert result == snapshot(exclude=props("created_at", "modified_at", "entry_id"))
|
Loading…
x
Reference in New Issue
Block a user