File tree Expand file tree Collapse file tree 3 files changed +105
-0
lines changed
homeassistant/components/senz Expand file tree Collapse file tree 3 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 1+ """Diagnostics platform for Senz integration."""
2+
3+ from typing import Any
4+
5+ from homeassistant .components .diagnostics import async_redact_data
6+ from homeassistant .config_entries import ConfigEntry
7+ from homeassistant .core import HomeAssistant
8+
9+ from .const import DOMAIN
10+
11+ TO_REDACT = [
12+ "access_token" ,
13+ "refresh_token" ,
14+ ]
15+
16+
17+ async def async_get_config_entry_diagnostics (
18+ hass : HomeAssistant , entry : ConfigEntry
19+ ) -> dict [str , Any ]:
20+ """Return diagnostics for a config entry."""
21+
22+ raw_data = (
23+ [device .raw_data for device in hass .data [DOMAIN ][entry .entry_id ].data .values ()],
24+ )
25+
26+ return {
27+ "entry_data" : async_redact_data (entry .data , TO_REDACT ),
28+ "thermostats" : raw_data ,
29+ }
Original file line number Diff line number Diff line change 1+ # serializer version: 1
2+ # name: test_diagnostics_config_entry
3+ dict({
4+ 'entry_data': dict({
5+ 'auth_implementation': 'senz',
6+ 'token': dict({
7+ 'access_token': '**REDACTED**',
8+ 'expires_in': 86399,
9+ 'refresh_token': '**REDACTED**',
10+ 'token_type': 'Bearer',
11+ }),
12+ }),
13+ 'thermostats': list([
14+ list([
15+ dict({
16+ 'currentTemperature': 1845,
17+ 'errorState': None,
18+ 'holdUntil': None,
19+ 'isHeating': True,
20+ 'mode': 5,
21+ 'name': 'Test room 1',
22+ 'online': True,
23+ 'serialNumber': '1001',
24+ 'setPointTemperature': 1900,
25+ }),
26+ dict({
27+ 'currentTemperature': 930,
28+ 'errorState': None,
29+ 'holdUntil': None,
30+ 'isHeating': False,
31+ 'mode': 1,
32+ 'name': 'Test room 2',
33+ 'online': True,
34+ 'serialNumber': '1002',
35+ 'setPointTemperature': 600,
36+ }),
37+ ]),
38+ ]),
39+ })
40+ # ---
Original file line number Diff line number Diff line change 1+ """Tests for the diagnostics data provided by the senz integration."""
2+
3+ from collections .abc import Generator
4+ from unittest .mock import MagicMock
5+
6+ from syrupy .assertion import SnapshotAssertion
7+ from syrupy .filters import paths
8+
9+ from homeassistant .core import HomeAssistant
10+
11+ from . import setup_integration
12+
13+ from tests .common import MockConfigEntry
14+ from tests .components .diagnostics import get_diagnostics_for_config_entry
15+ from tests .typing import ClientSessionGenerator
16+
17+
18+ async def test_diagnostics_config_entry (
19+ hass : HomeAssistant ,
20+ hass_client : ClientSessionGenerator ,
21+ mock_senz_client : Generator [MagicMock ],
22+ mock_config_entry : MockConfigEntry ,
23+ snapshot : SnapshotAssertion ,
24+ ) -> None :
25+ """Test diagnostics for config entry."""
26+
27+ await setup_integration (hass , mock_config_entry )
28+ result = await get_diagnostics_for_config_entry (
29+ hass , hass_client , mock_config_entry
30+ )
31+
32+ assert result == snapshot (
33+ exclude = paths (
34+ "entry_data.token.expires_at" ,
35+ )
36+ )
You can’t perform that action at this time.
0 commit comments