mirror of
https://github.com/home-assistant/core.git
synced 2025-09-13 16:51:37 +02:00
Add diagnostics platform to Sleep as Android (#150447)
This commit is contained in:
19
homeassistant/components/sleep_as_android/diagnostics.py
Normal file
19
homeassistant/components/sleep_as_android/diagnostics.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
"""Diagnostics platform for Sleep as Android integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from . import SleepAsAndroidConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_config_entry_diagnostics(
|
||||||
|
hass: HomeAssistant, config_entry: SleepAsAndroidConfigEntry
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""Return diagnostics for a config entry."""
|
||||||
|
|
||||||
|
return {
|
||||||
|
"config_entry_data": {"cloudhook": config_entry.data["cloudhook"]},
|
||||||
|
}
|
@@ -61,7 +61,7 @@ rules:
|
|||||||
|
|
||||||
# Gold
|
# Gold
|
||||||
devices: done
|
devices: done
|
||||||
diagnostics: todo
|
diagnostics: done
|
||||||
discovery-update-info:
|
discovery-update-info:
|
||||||
status: exempt
|
status: exempt
|
||||||
comment: no discovery
|
comment: no discovery
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_diagnostics
|
||||||
|
dict({
|
||||||
|
'config_entry_data': dict({
|
||||||
|
'cloudhook': False,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
26
tests/components/sleep_as_android/test_diagnostics.py
Normal file
26
tests/components/sleep_as_android/test_diagnostics.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
"""Tests for Sleep as Android diagnostics."""
|
||||||
|
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||||
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
async def test_diagnostics(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
config_entry: MockConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
|
"""Test diagnostics."""
|
||||||
|
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert (
|
||||||
|
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||||
|
== snapshot
|
||||||
|
)
|
Reference in New Issue
Block a user