mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add Google Assistant SDK diagnostics (#118513)
This commit is contained in:
parent
eae04bf2e9
commit
2b7685b71d
24
homeassistant/components/google_assistant_sdk/diagnostics.py
Normal file
24
homeassistant/components/google_assistant_sdk/diagnostics.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""Diagnostics support for Google Assistant SDK."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
TO_REDACT = {"access_token", "refresh_token"}
|
||||||
|
|
||||||
|
|
||||||
|
async def async_get_config_entry_diagnostics(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
"""Return diagnostics for a config entry."""
|
||||||
|
return async_redact_data(
|
||||||
|
{
|
||||||
|
"data": entry.data,
|
||||||
|
"options": entry.options,
|
||||||
|
},
|
||||||
|
TO_REDACT,
|
||||||
|
)
|
@ -119,7 +119,6 @@ NO_DIAGNOSTICS = [
|
|||||||
"dlna_dms",
|
"dlna_dms",
|
||||||
"gdacs",
|
"gdacs",
|
||||||
"geonetnz_quakes",
|
"geonetnz_quakes",
|
||||||
"google_assistant_sdk",
|
|
||||||
"hyperion",
|
"hyperion",
|
||||||
# Modbus is excluded because it doesn't have to have a config flow
|
# Modbus is excluded because it doesn't have to have a config flow
|
||||||
# according to ADR-0010, since it's a protocol integration. This
|
# according to ADR-0010, since it's a protocol integration. This
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
# serializer version: 1
|
||||||
|
# name: test_diagnostics
|
||||||
|
dict({
|
||||||
|
'data': dict({
|
||||||
|
'auth_implementation': 'google_assistant_sdk',
|
||||||
|
'token': dict({
|
||||||
|
'access_token': '**REDACTED**',
|
||||||
|
'expires_at': 1717074000.0,
|
||||||
|
'refresh_token': '**REDACTED**',
|
||||||
|
'scope': 'https://www.googleapis.com/auth/assistant-sdk-prototype',
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
'options': dict({
|
||||||
|
'language_code': 'en-US',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
# ---
|
38
tests/components/google_assistant_sdk/test_diagnostics.py
Normal file
38
tests/components/google_assistant_sdk/test_diagnostics.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
"""Tests for the diagnostics data provided by the Google Assistant SDK integration."""
|
||||||
|
|
||||||
|
from freezegun import freeze_time
|
||||||
|
import pytest
|
||||||
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
|
from homeassistant.components.google_assistant_sdk.const import CONF_LANGUAGE_CODE
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def freeze_the_time():
|
||||||
|
"""Freeze the time."""
|
||||||
|
with freeze_time("2024-05-30 12:00:00", tz_offset=0):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
async def test_diagnostics(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
hass_client: ClientSessionGenerator,
|
||||||
|
config_entry: MockConfigEntry,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
|
) -> None:
|
||||||
|
"""Test diagnostics."""
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
hass.config_entries.async_update_entry(
|
||||||
|
config_entry,
|
||||||
|
options={CONF_LANGUAGE_CODE: "en-US"},
|
||||||
|
)
|
||||||
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
assert (
|
||||||
|
await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
||||||
|
== snapshot
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user