core/tests/components/google_assistant/test_diagnostics.py

54 lines
1.5 KiB
Python

"""Test diagnostics."""
from unittest.mock import patch
import pytest
from syrupy import SnapshotAssertion
from syrupy.filters import props
from homeassistant import setup
from homeassistant.components import google_assistant as ga, switch
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
from .test_http import DUMMY_CONFIG
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
@pytest.fixture(autouse=True)
async def switch_only() -> None:
"""Enable only the switch platform."""
with patch(
"homeassistant.components.demo.COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM",
[Platform.SWITCH],
):
yield
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics v1."""
await async_setup_component(hass, "homeassistant", {})
await setup.async_setup_component(
hass, switch.DOMAIN, {"switch": [{"platform": "demo"}]}
)
await async_setup_component(
hass,
ga.DOMAIN,
{"google_assistant": DUMMY_CONFIG},
)
await hass.async_block_till_done()
config_entry = hass.config_entries.async_entries("google_assistant")[0]
assert await get_diagnostics_for_config_entry(
hass, hass_client, config_entry
) == snapshot(exclude=props("entry_id", "created_at", "modified_at"))