mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add diagnostics to Overseerr (#136094)
This commit is contained in:
parent
63f14b9487
commit
3f8f206c53
26
homeassistant/components/overseerr/diagnostics.py
Normal file
26
homeassistant/components/overseerr/diagnostics.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Diagnostics support for Overseerr."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import asdict
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import CONF_CLOUDHOOK_URL
|
||||
from .coordinator import OverseerrConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: OverseerrConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
|
||||
has_cloudhooks = CONF_CLOUDHOOK_URL in entry.data
|
||||
|
||||
data = entry.runtime_data
|
||||
|
||||
return {
|
||||
"has_cloudhooks": has_cloudhooks,
|
||||
"coordinator_data": asdict(data.data),
|
||||
}
|
@ -41,7 +41,7 @@ rules:
|
||||
test-coverage: todo
|
||||
# Gold
|
||||
devices: done
|
||||
diagnostics: todo
|
||||
diagnostics: done
|
||||
discovery-update-info:
|
||||
status: exempt
|
||||
comment: |
|
||||
|
31
tests/components/overseerr/snapshots/test_diagnostics.ambr
Normal file
31
tests/components/overseerr/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,31 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics_polling_instance
|
||||
dict({
|
||||
'coordinator_data': dict({
|
||||
'approved': 11,
|
||||
'available': 8,
|
||||
'declined': 0,
|
||||
'movie': 9,
|
||||
'pending': 0,
|
||||
'processing': 3,
|
||||
'total': 11,
|
||||
'tv': 2,
|
||||
}),
|
||||
'has_cloudhooks': False,
|
||||
})
|
||||
# ---
|
||||
# name: test_diagnostics_webhook_instance
|
||||
dict({
|
||||
'coordinator_data': dict({
|
||||
'approved': 11,
|
||||
'available': 8,
|
||||
'declined': 0,
|
||||
'movie': 9,
|
||||
'pending': 0,
|
||||
'processing': 3,
|
||||
'total': 11,
|
||||
'tv': 2,
|
||||
}),
|
||||
'has_cloudhooks': True,
|
||||
})
|
||||
# ---
|
47
tests/components/overseerr/test_diagnostics.py
Normal file
47
tests/components/overseerr/test_diagnostics.py
Normal file
@ -0,0 +1,47 @@
|
||||
"""Tests for the diagnostics data provided by the Overseerr 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_polling_instance(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_overseerr_client: 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
|
||||
)
|
||||
|
||||
|
||||
async def test_diagnostics_webhook_instance(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mock_overseerr_client_cloudhook: AsyncMock,
|
||||
mock_cloudhook_config_entry: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
await setup_integration(hass, mock_cloudhook_config_entry)
|
||||
|
||||
assert (
|
||||
await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_cloudhook_config_entry
|
||||
)
|
||||
== snapshot
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user