mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add diagnostics support to RDW (#64787)
This commit is contained in:
parent
0ae2ffd467
commit
d8b6291806
23
homeassistant/components/rdw/diagnostics.py
Normal file
23
homeassistant/components/rdw/diagnostics.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""Diagnostics support for RDW."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
from vehicle import Vehicle
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
coordinator: DataUpdateCoordinator[Vehicle] = hass.data[DOMAIN][entry.entry_id]
|
||||
# Round-trip via JSON to trigger serialization
|
||||
data: dict[str, Any] = json.loads(coordinator.data.json())
|
||||
return data
|
45
tests/components/rdw/test_diagnostics.py
Normal file
45
tests/components/rdw/test_diagnostics.py
Normal file
@ -0,0 +1,45 @@
|
||||
"""Tests for the diagnostics data provided by the RDW integration."""
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSession,
|
||||
init_integration: MockConfigEntry,
|
||||
):
|
||||
"""Test diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, init_integration
|
||||
) == {
|
||||
"apk_expiration": "2022-01-04",
|
||||
"ascription_date": "2021-11-04",
|
||||
"ascription_possible": True,
|
||||
"brand": "Skoda",
|
||||
"energy_label": "A",
|
||||
"engine_capacity": 999,
|
||||
"exported": False,
|
||||
"interior": "hatchback",
|
||||
"last_odometer_registration_year": 2021,
|
||||
"liability_insured": False,
|
||||
"license_plate": "11ZKZ3",
|
||||
"list_price": 10697,
|
||||
"first_admission": "2013-01-04",
|
||||
"first_admission_netherlands": "2013-01-04",
|
||||
"mass_empty": 840,
|
||||
"mass_driveable": 940,
|
||||
"model": "Citigo",
|
||||
"number_of_cylinders": 3,
|
||||
"number_of_doors": 0,
|
||||
"number_of_seats": 4,
|
||||
"number_of_wheelchair_seats": 0,
|
||||
"number_of_wheels": 4,
|
||||
"odometer_judgement": "Logisch",
|
||||
"pending_recall": False,
|
||||
"taxi": None,
|
||||
"vehicle_type": "Personenauto",
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user