Add diagnostics to proximity (#109393)
This commit is contained in:
parent
4809327124
commit
e567236cac
3 changed files with 197 additions and 0 deletions
62
tests/components/proximity/test_diagnostics.py
Normal file
62
tests/components/proximity/test_diagnostics.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
"""Tests for proximity diagnostics platform."""
|
||||
from __future__ import annotations
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.filters import props
|
||||
|
||||
from homeassistant.components.proximity.const import (
|
||||
CONF_IGNORED_ZONES,
|
||||
CONF_TOLERANCE,
|
||||
CONF_TRACKED_ENTITIES,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_ZONE
|
||||
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_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test config entry diagnostics."""
|
||||
hass.states.async_set(
|
||||
"device_tracker.test1",
|
||||
"not_home",
|
||||
{"friendly_name": "test1", "latitude": 20.1, "longitude": 10.1},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"device_tracker.test2",
|
||||
"not_home",
|
||||
{"friendly_name": "test2", "latitude": 150.1, "longitude": 20.1},
|
||||
)
|
||||
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
title="home",
|
||||
data={
|
||||
CONF_ZONE: "zone.home",
|
||||
CONF_TRACKED_ENTITIES: [
|
||||
"device_tracker.test1",
|
||||
"device_tracker.test2",
|
||||
"device_tracker.test3",
|
||||
],
|
||||
CONF_IGNORED_ZONES: [],
|
||||
CONF_TOLERANCE: 1,
|
||||
},
|
||||
unique_id=f"{DOMAIN}_home",
|
||||
)
|
||||
|
||||
mock_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_entry.state == ConfigEntryState.LOADED
|
||||
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, mock_entry
|
||||
) == snapshot(exclude=props("entry_id", "last_changed", "last_updated"))
|
Loading…
Add table
Add a link
Reference in a new issue