Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3f8f206

Browse files
Add diagnostics to Overseerr (home-assistant#136094)
1 parent 63f14b9 commit 3f8f206

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Diagnostics support for Overseerr."""
2+
3+
from __future__ import annotations
4+
5+
from dataclasses import asdict
6+
from typing import Any
7+
8+
from homeassistant.core import HomeAssistant
9+
10+
from . import CONF_CLOUDHOOK_URL
11+
from .coordinator import OverseerrConfigEntry
12+
13+
14+
async def async_get_config_entry_diagnostics(
15+
hass: HomeAssistant, entry: OverseerrConfigEntry
16+
) -> dict[str, Any]:
17+
"""Return diagnostics for a config entry."""
18+
19+
has_cloudhooks = CONF_CLOUDHOOK_URL in entry.data
20+
21+
data = entry.runtime_data
22+
23+
return {
24+
"has_cloudhooks": has_cloudhooks,
25+
"coordinator_data": asdict(data.data),
26+
}

‎homeassistant/components/overseerr/quality_scale.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rules:
4141
test-coverage: todo
4242
# Gold
4343
devices: done
44-
diagnostics: todo
44+
diagnostics: done
4545
discovery-update-info:
4646
status: exempt
4747
comment: |
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# serializer version: 1
2+
# name: test_diagnostics_polling_instance
3+
dict({
4+
'coordinator_data': dict({
5+
'approved': 11,
6+
'available': 8,
7+
'declined': 0,
8+
'movie': 9,
9+
'pending': 0,
10+
'processing': 3,
11+
'total': 11,
12+
'tv': 2,
13+
}),
14+
'has_cloudhooks': False,
15+
})
16+
# ---
17+
# name: test_diagnostics_webhook_instance
18+
dict({
19+
'coordinator_data': dict({
20+
'approved': 11,
21+
'available': 8,
22+
'declined': 0,
23+
'movie': 9,
24+
'pending': 0,
25+
'processing': 3,
26+
'total': 11,
27+
'tv': 2,
28+
}),
29+
'has_cloudhooks': True,
30+
})
31+
# ---
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""Tests for the diagnostics data provided by the Overseerr integration."""
2+
3+
from unittest.mock import AsyncMock
4+
5+
from syrupy import SnapshotAssertion
6+
7+
from homeassistant.core import HomeAssistant
8+
9+
from . import setup_integration
10+
11+
from tests.common import MockConfigEntry
12+
from tests.components.diagnostics import get_diagnostics_for_config_entry
13+
from tests.typing import ClientSessionGenerator
14+
15+
16+
async def test_diagnostics_polling_instance(
17+
hass: HomeAssistant,
18+
hass_client: ClientSessionGenerator,
19+
mock_overseerr_client: AsyncMock,
20+
mock_config_entry: MockConfigEntry,
21+
snapshot: SnapshotAssertion,
22+
) -> None:
23+
"""Test diagnostics."""
24+
await setup_integration(hass, mock_config_entry)
25+
26+
assert (
27+
await get_diagnostics_for_config_entry(hass, hass_client, mock_config_entry)
28+
== snapshot
29+
)
30+
31+
32+
async def test_diagnostics_webhook_instance(
33+
hass: HomeAssistant,
34+
hass_client: ClientSessionGenerator,
35+
mock_overseerr_client_cloudhook: AsyncMock,
36+
mock_cloudhook_config_entry: MockConfigEntry,
37+
snapshot: SnapshotAssertion,
38+
) -> None:
39+
"""Test diagnostics."""
40+
await setup_integration(hass, mock_cloudhook_config_entry)
41+
42+
assert (
43+
await get_diagnostics_for_config_entry(
44+
hass, hass_client, mock_cloudhook_config_entry
45+
)
46+
== snapshot
47+
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /