core/tests/components/twentemilieu/test_sensor.py

38 lines
1.2 KiB
Python
Raw Normal View History

"""Tests for the Twente Milieu sensors."""
2023-02-23 15:26:17 +00:00
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
2023-02-23 15:26:17 +00:00
pytestmark = pytest.mark.usefixtures("init_integration")
2023-02-23 15:26:17 +00:00
@pytest.mark.parametrize(
"entity_id",
[
"sensor.twente_milieu_christmas_tree_pickup",
"sensor.twente_milieu_non_recyclable_waste_pickup",
"sensor.twente_milieu_organic_waste_pickup",
"sensor.twente_milieu_packages_waste_pickup",
"sensor.twente_milieu_paper_waste_pickup",
],
)
async def test_sensors(
hass: HomeAssistant,
2023-02-23 15:26:17 +00:00
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
entity_id: str,
) -> None:
"""Test the Twente Milieu waste pickup sensors."""
2023-02-23 15:26:17 +00:00
assert (state := hass.states.get(entity_id))
assert state == snapshot
2023-02-23 15:26:17 +00:00
assert (entity_entry := entity_registry.async_get(state.entity_id))
assert entity_entry == snapshot
2023-02-23 15:26:17 +00:00
assert entity_entry.device_id
assert (device_entry := device_registry.async_get(entity_entry.device_id))
assert device_entry == snapshot