1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Use mock_restore_cache in mqtt tests (#77297)

This commit is contained in:
Erik Montnemery
2022-08-25 09:27:38 +02:00
committed by GitHub
parent cef6ffb552
commit c55505b47b
9 changed files with 152 additions and 170 deletions

View File

@@ -25,6 +25,8 @@ from .test_common import (
help_test_unload_config_entry_with_platform,
)
from tests.common import mock_restore_cache
DEFAULT_CONFIG = {
scene.DOMAIN: {
"platform": "mqtt",
@@ -45,25 +47,22 @@ def scene_platform_only():
async def test_sending_mqtt_commands(hass, mqtt_mock_entry_with_yaml_config):
"""Test the sending MQTT commands."""
fake_state = ha.State("scene.test", STATE_UNKNOWN)
mock_restore_cache(hass, (fake_state,))
with patch(
"homeassistant.helpers.restore_state.RestoreEntity.async_get_last_state",
return_value=fake_state,
):
assert await async_setup_component(
hass,
scene.DOMAIN,
{
scene.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"payload_on": "beer on",
},
assert await async_setup_component(
hass,
scene.DOMAIN,
{
scene.DOMAIN: {
"platform": "mqtt",
"name": "test",
"command_topic": "command-topic",
"payload_on": "beer on",
},
)
await hass.async_block_till_done()
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
},
)
await hass.async_block_till_done()
mqtt_mock = await mqtt_mock_entry_with_yaml_config()
state = hass.states.get("scene.test")
assert state.state == STATE_UNKNOWN