mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use entity_registry_enabled_by_default fixture in dsmr_reader tests (#147891)
This commit is contained in:
parent
5e03900e0a
commit
d6fb860889
@ -4,15 +4,13 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant.components.dsmr_reader.const import DOMAIN
|
from homeassistant.components.dsmr_reader.const import DOMAIN
|
||||||
from homeassistant.components.dsmr_reader.definitions import (
|
from homeassistant.components.dsmr_reader.definitions import (
|
||||||
DSMRReaderSensorEntityDescription,
|
|
||||||
dsmr_transform,
|
dsmr_transform,
|
||||||
tariff_transform,
|
tariff_transform,
|
||||||
)
|
)
|
||||||
from homeassistant.components.dsmr_reader.sensor import DSMRSensor
|
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant
|
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(
|
@pytest.mark.parametrize(
|
||||||
@ -71,7 +69,7 @@ async def test_entity_tariff(hass: HomeAssistant) -> None:
|
|||||||
assert hass.states.get(electricity_tariff).state == "low"
|
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:
|
async def test_entity_dsmr_transform(hass: HomeAssistant) -> None:
|
||||||
"""Test the state attribute of DSMRReaderSensorEntityDescription when a dsmr transform is needed."""
|
"""Test the state attribute of DSMRReaderSensorEntityDescription when a dsmr transform is needed."""
|
||||||
config_entry = MockConfigEntry(
|
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)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
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
|
# Test dsmr version, if it's a digit
|
||||||
async_fire_mqtt_message(hass, "dsmr/meter-stats/dsmr_version", "42")
|
async_fire_mqtt_message(hass, "dsmr/meter-stats/dsmr_version", "42")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user