mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Use setup_test_component_platform
helper for sensor entity component tests instead of hass.components
(#114316)
* Use `setup_test_component_platform` helper for sensor entity component tests instead of `hass.components` * Missing file * Fix import * Remove invalid device class
This commit is contained in:
committed by
GitHub
parent
41bd3d0853
commit
22b14d83e8
@ -23,6 +23,7 @@ from homeassistant.components.mqtt.models import (
|
||||
MqttValueTemplateException,
|
||||
ReceiveMessage,
|
||||
)
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.config_entries import ConfigEntryDisabler, ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
ATTR_ASSUMED_STATE,
|
||||
@ -52,10 +53,9 @@ from tests.common import (
|
||||
async_fire_mqtt_message,
|
||||
async_fire_time_changed,
|
||||
mock_restore_cache,
|
||||
setup_test_component_platform,
|
||||
)
|
||||
from tests.testing_config.custom_components.test.sensor import ( # type: ignore[attr-defined]
|
||||
DEVICE_CLASSES,
|
||||
)
|
||||
from tests.components.sensor.common import MockSensor
|
||||
from tests.typing import (
|
||||
MqttMockHAClient,
|
||||
MqttMockHAClientGenerator,
|
||||
@ -3142,12 +3142,12 @@ async def test_debug_info_non_mqtt(
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
mock_sensor_entities: dict[str, MockSensor],
|
||||
) -> None:
|
||||
"""Test we get empty debug_info for a device with non MQTT entities."""
|
||||
await mqtt_mock_entry()
|
||||
domain = "sensor"
|
||||
platform = getattr(hass.components, f"test.{domain}")
|
||||
platform.init()
|
||||
setup_test_component_platform(hass, domain, mock_sensor_entities)
|
||||
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
@ -3155,11 +3155,11 @@ async def test_debug_info_non_mqtt(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
for device_class in DEVICE_CLASSES:
|
||||
for device_class in SensorDeviceClass:
|
||||
entity_registry.async_get_or_create(
|
||||
domain,
|
||||
"test",
|
||||
platform.ENTITIES[device_class].unique_id,
|
||||
mock_sensor_entities[device_class].unique_id,
|
||||
device_id=device_entry.id,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user