mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Ensure an entity platform is added in mqtt tests (#134331)
This commit is contained in:
parent
1d6ecbd1d5
commit
8098122dfe
@ -44,6 +44,7 @@ from homeassistant.util.dt import utcnow
|
|||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
MockEntity,
|
MockEntity,
|
||||||
|
MockEntityPlatform,
|
||||||
async_fire_mqtt_message,
|
async_fire_mqtt_message,
|
||||||
async_fire_time_changed,
|
async_fire_time_changed,
|
||||||
mock_restore_cache,
|
mock_restore_cache,
|
||||||
@ -194,6 +195,7 @@ async def test_value_template_value(hass: HomeAssistant) -> None:
|
|||||||
# test value template with entity
|
# test value template with entity
|
||||||
entity = Entity()
|
entity = Entity()
|
||||||
entity.hass = hass
|
entity.hass = hass
|
||||||
|
entity.platform = MockEntityPlatform(hass)
|
||||||
entity.entity_id = "select.test"
|
entity.entity_id = "select.test"
|
||||||
tpl = template.Template("{{ value_json.id }}", hass=hass)
|
tpl = template.Template("{{ value_json.id }}", hass=hass)
|
||||||
val_tpl = mqtt.MqttValueTemplate(tpl, entity=entity)
|
val_tpl = mqtt.MqttValueTemplate(tpl, entity=entity)
|
||||||
@ -218,6 +220,7 @@ async def test_value_template_fails(hass: HomeAssistant) -> None:
|
|||||||
"""Test the rendering of MQTT value template fails."""
|
"""Test the rendering of MQTT value template fails."""
|
||||||
entity = MockEntity(entity_id="sensor.test")
|
entity = MockEntity(entity_id="sensor.test")
|
||||||
entity.hass = hass
|
entity.hass = hass
|
||||||
|
entity.platform = MockEntityPlatform(hass)
|
||||||
tpl = template.Template("{{ value_json.some_var * 2 }}", hass=hass)
|
tpl = template.Template("{{ value_json.some_var * 2 }}", hass=hass)
|
||||||
val_tpl = mqtt.MqttValueTemplate(tpl, entity=entity)
|
val_tpl = mqtt.MqttValueTemplate(tpl, entity=entity)
|
||||||
with pytest.raises(MqttValueTemplateException) as exc:
|
with pytest.raises(MqttValueTemplateException) as exc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user