mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Add diagnostics platform to Russound RIO (#132776)
This commit is contained in:
parent
3bf4ef095d
commit
bcedb004be
14
homeassistant/components/russound_rio/diagnostics.py
Normal file
14
homeassistant/components/russound_rio/diagnostics.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"""Diagnostics platform for Russound RIO."""
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from . import RussoundConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_config_entry_diagnostics(
|
||||||
|
hass: HomeAssistant, entry: RussoundConfigEntry
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""Return diagnostics for the provided config entry."""
|
||||||
|
return entry.runtime_data.state
|
@ -54,6 +54,7 @@ def mock_russound_client() -> Generator[AsyncMock]:
|
|||||||
int(k): Source.from_dict(v)
|
int(k): Source.from_dict(v)
|
||||||
for k, v in load_json_object_fixture("get_sources.json", DOMAIN).items()
|
for k, v in load_json_object_fixture("get_sources.json", DOMAIN).items()
|
||||||
}
|
}
|
||||||
|
client.state = load_json_object_fixture("get_state.json", DOMAIN)
|
||||||
for k, v in zones.items():
|
for k, v in zones.items():
|
||||||
v.device_str = zone_device_str(1, k)
|
v.device_str = zone_device_str(1, k)
|
||||||
v.fetch_current_source = Mock(
|
v.fetch_current_source = Mock(
|
||||||
|
75
tests/components/russound_rio/fixtures/get_state.json
Normal file
75
tests/components/russound_rio/fixtures/get_state.json
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"S": {
|
||||||
|
"3": {
|
||||||
|
"name": "Streamer",
|
||||||
|
"type": "Misc Audio"
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"name": "Liv. Rm TV",
|
||||||
|
"type": "Misc Audio"
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"name": "Source 5",
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"name": "Basement TV",
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"name": "Tuner",
|
||||||
|
"type": "DMS-3.1 Media Streamer",
|
||||||
|
"channelName": null,
|
||||||
|
"coverArtURL": null,
|
||||||
|
"mode": "Unknown",
|
||||||
|
"shuffleMode": null,
|
||||||
|
"repeatMode": null,
|
||||||
|
"volume": "0",
|
||||||
|
"rating": null,
|
||||||
|
"playlistName": "Please Wait...",
|
||||||
|
"artistName": null,
|
||||||
|
"albumName": null,
|
||||||
|
"songName": "Connecting to media source."
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
"name": "Source 6",
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"8": {
|
||||||
|
"name": "Source 8",
|
||||||
|
"type": null
|
||||||
|
},
|
||||||
|
"7": {
|
||||||
|
"name": "Source 7",
|
||||||
|
"type": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"System": {
|
||||||
|
"status": "OFF"
|
||||||
|
},
|
||||||
|
"C": {
|
||||||
|
"1": {
|
||||||
|
"Z": {
|
||||||
|
"1": {
|
||||||
|
"name": "Deck",
|
||||||
|
"treble": "0",
|
||||||
|
"balance": "0",
|
||||||
|
"loudness": "OFF",
|
||||||
|
"turnOnVolume": "10",
|
||||||
|
"doNotDisturb": "OFF",
|
||||||
|
"currentSource": "2",
|
||||||
|
"volume": "0",
|
||||||
|
"status": "OFF",
|
||||||
|
"mute": "OFF",
|
||||||
|
"partyMode": "OFF",
|
||||||
|
"bass": "0",
|
||||||
|
"page": "OFF",
|
||||||
|
"sharedSource": "OFF",
|
||||||
|
"sleepTimeRemaining": "0",
|
||||||
|
"lastError": null,
|
||||||
|
"enabled_sources": [3, 2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_entry_diagnostics
|
||||||
|
dict({
|
||||||
|
'C': dict({
|
||||||
|
'1': dict({
|
||||||
|
'Z': dict({
|
||||||
|
'1': dict({
|
||||||
|
'balance': '0',
|
||||||
|
'bass': '0',
|
||||||
|
'currentSource': '2',
|
||||||
|
'doNotDisturb': 'OFF',
|
||||||
|
'enabled_sources': list([
|
||||||
|
3,
|
||||||
|
2,
|
||||||
|
]),
|
||||||
|
'lastError': None,
|
||||||
|
'loudness': 'OFF',
|
||||||
|
'mute': 'OFF',
|
||||||
|
'name': 'Deck',
|
||||||
|
'page': 'OFF',
|
||||||
|
'partyMode': 'OFF',
|
||||||
|
'sharedSource': 'OFF',
|
||||||
|
'sleepTimeRemaining': '0',
|
||||||
|
'status': 'OFF',
|
||||||
|
'treble': '0',
|
||||||
|
'turnOnVolume': '10',
|
||||||
|
'volume': '0',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'S': dict({
|
||||||
|
'1': dict({
|
||||||
|
'albumName': None,
|
||||||
|
'artistName': None,
|
||||||
|
'channelName': None,
|
||||||
|
'coverArtURL': None,
|
||||||
|
'mode': 'Unknown',
|
||||||
|
'name': 'Tuner',
|
||||||
|
'playlistName': 'Please Wait...',
|
||||||
|
'rating': None,
|
||||||
|
'repeatMode': None,
|
||||||
|
'shuffleMode': None,
|
||||||
|
'songName': 'Connecting to media source.',
|
||||||
|
'type': 'DMS-3.1 Media Streamer',
|
||||||
|
'volume': '0',
|
||||||
|
}),
|
||||||
|
'2': dict({
|
||||||
|
'name': 'Liv. Rm TV',
|
||||||
|
'type': 'Misc Audio',
|
||||||
|
}),
|
||||||
|
'3': dict({
|
||||||
|
'name': 'Streamer',
|
||||||
|
'type': 'Misc Audio',
|
||||||
|
}),
|
||||||
|
'4': dict({
|
||||||
|
'name': 'Basement TV',
|
||||||
|
'type': None,
|
||||||
|
}),
|
||||||
|
'5': dict({
|
||||||
|
'name': 'Source 5',
|
||||||
|
'type': None,
|
||||||
|
}),
|
||||||
|
'6': dict({
|
||||||
|
'name': 'Source 6',
|
||||||
|
'type': None,
|
||||||
|
}),
|
||||||
|
'7': dict({
|
||||||
|
'name': 'Source 7',
|
||||||
|
'type': None,
|
||||||
|
}),
|
||||||
|
'8': dict({
|
||||||
|
'name': 'Source 8',
|
||||||
|
'type': None,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'System': dict({
|
||||||
|
'status': 'OFF',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
29
tests/components/russound_rio/test_diagnostics.py
Normal file
29
tests/components/russound_rio/test_diagnostics.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"""Tests for the diagnostics data provided by the Russound RIO 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_entry_diagnostics(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
mock_russound_client: AsyncMock,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> 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
|
Loading…
x
Reference in New Issue
Block a user