Use entity_registry_enabled_by_default fixture in dsmr_reader tests (#147891)

This commit is contained in:
Erik Montnemery 2025-07-01 20:50:38 +02:00 committed by GitHub
parent 5e03900e0a
commit d6fb860889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,15 +4,13 @@ import pytest
from homeassistant.components.dsmr_reader.const import DOMAIN
from homeassistant.components.dsmr_reader.definitions import (
DSMRReaderSensorEntityDescription,
dsmr_transform,
tariff_transform,
)
from homeassistant.components.dsmr_reader.sensor import DSMRSensor
from homeassistant.const import STATE_UNKNOWN
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, MockEntityPlatform, async_fire_mqtt_message
from tests.common import MockConfigEntry, async_fire_mqtt_message
@pytest.mark.parametrize(
@ -71,7 +69,7 @@ async def test_entity_tariff(hass: HomeAssistant) -> None:
assert hass.states.get(electricity_tariff).state == "low"
@pytest.mark.usefixtures("mqtt_mock")
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "mqtt_mock")
async def test_entity_dsmr_transform(hass: HomeAssistant) -> None:
"""Test the state attribute of DSMRReaderSensorEntityDescription when a dsmr transform is needed."""
config_entry = MockConfigEntry(
@ -85,17 +83,6 @@ async def test_entity_dsmr_transform(hass: HomeAssistant) -> None:
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Create the entity, since it's not by default
description = DSMRReaderSensorEntityDescription(
key="dsmr/meter-stats/dsmr_version",
name="version_test",
state=dsmr_transform,
)
sensor = DSMRSensor(description, config_entry)
sensor.hass = hass
sensor.platform = MockEntityPlatform(hass)
await sensor.async_added_to_hass()
# Test dsmr version, if it's a digit
async_fire_mqtt_message(hass, "dsmr/meter-stats/dsmr_version", "42")
await hass.async_block_till_done()