mirror of
https://github.com/home-assistant/core.git
synced 2026-09-08 06:31:35 +01:00
83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
"""Tests for the Elgato sensor platform."""
|
|
|
|
import pytest
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
|
|
|
pytestmark = [
|
|
pytest.mark.parametrize("device_fixtures", ["key-light-mini"]),
|
|
pytest.mark.usefixtures("device_fixtures", "init_integration", "mock_elgato"),
|
|
]
|
|
|
|
|
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
|
@pytest.mark.parametrize(
|
|
"entity_id",
|
|
[
|
|
"sensor.frenck_battery",
|
|
"sensor.frenck_battery_voltage",
|
|
"sensor.frenck_charging_current",
|
|
"sensor.frenck_charging_power",
|
|
"sensor.frenck_charging_voltage",
|
|
"sensor.frenck_wi_fi_rssi",
|
|
"sensor.frenck_wi_fi_signal_strength",
|
|
],
|
|
)
|
|
async def test_sensors(
|
|
hass: HomeAssistant,
|
|
device_registry: dr.DeviceRegistry,
|
|
entity_registry: er.EntityRegistry,
|
|
snapshot: SnapshotAssertion,
|
|
entity_id: str,
|
|
) -> None:
|
|
"""Test the Elgato sensors."""
|
|
|
|
assert (state := hass.states.get(entity_id))
|
|
assert state == snapshot
|
|
|
|
assert (entry := entity_registry.async_get(entity_id))
|
|
assert entry == snapshot
|
|
|
|
assert entry.device_id
|
|
assert (device_entry := device_registry.async_get(entry.device_id))
|
|
assert device_entry == snapshot
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"entity_id",
|
|
[
|
|
"sensor.frenck_battery_voltage",
|
|
"sensor.frenck_charging_current",
|
|
"sensor.frenck_charging_power",
|
|
"sensor.frenck_charging_voltage",
|
|
"sensor.frenck_wi_fi_rssi",
|
|
],
|
|
)
|
|
async def test_disabled_by_default_sensors(
|
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, entity_id: str
|
|
) -> None:
|
|
"""Test the disabled by default Elgato sensors."""
|
|
assert not hass.states.get(entity_id)
|
|
|
|
assert (entry := entity_registry.async_get(entity_id))
|
|
assert entry.disabled
|
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
|
|
|
|
|
async def test_wifi_signal_strength_is_enabled(
|
|
hass: HomeAssistant,
|
|
entity_registry: er.EntityRegistry,
|
|
) -> None:
|
|
"""Test the signal strength percentage is on without asking for it.
|
|
|
|
A percentage is what someone can actually read, so it is the one that
|
|
shows up by default. The dBm behind it stays available but off.
|
|
"""
|
|
assert (state := hass.states.get("sensor.frenck_wi_fi_signal_strength"))
|
|
assert state.state == "100"
|
|
|
|
assert (entry := entity_registry.async_get("sensor.frenck_wi_fi_signal_strength"))
|
|
assert not entry.disabled
|