mirror of
https://github.com/elisspace/core.git
synced 2026-09-24 03:26:52 +00:00
* Add support for snapshot testing * Use snapshots in Elgato diagnostics test * Use snapshots in Elgato sensor test * Fix flake8 warning * Slightly improve serialized output * Remove snapshot naming in elgato sensor tests * Improve snapshoting of via_device_id in device registry item * Update pylint typehints plugin for snapshot fixture typing * Use snapshots in Elgato configflow test * Use snapshots in Bluetooth repair issue tests
65 lines
1.8 KiB
Python
65 lines
1.8 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",
|
|
],
|
|
)
|
|
async def test_sensors(
|
|
hass: HomeAssistant,
|
|
device_registry: dr.DeviceRegistry,
|
|
entity_registry: er.EntityRegistry,
|
|
snapshot: SnapshotAssertion,
|
|
entity_id: str,
|
|
) -> None:
|
|
"""Test the Elgato sensors."""
|
|
|
|
state = hass.states.get(entity_id)
|
|
assert state == snapshot
|
|
|
|
entry = entity_registry.async_get(entity_id)
|
|
assert entry == snapshot
|
|
|
|
assert entry.device_id
|
|
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",
|
|
],
|
|
)
|
|
async def test_disabled_by_default_sensors(
|
|
hass: HomeAssistant, entity_registry: er.EntityRegistry, entity_id: str
|
|
) -> None:
|
|
"""Test the disabled by default Elgato sensors."""
|
|
state = hass.states.get(entity_id)
|
|
assert state is None
|
|
|
|
entry = entity_registry.async_get(entity_id)
|
|
assert entry
|
|
assert entry.disabled
|
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|