mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Add the ability to reload generic_thermostat platforms from yaml (#39291)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
"""The tests for the generic_thermostat."""
|
||||
import datetime
|
||||
from os import path
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config as hass_config
|
||||
from homeassistant.components import input_boolean, switch
|
||||
from homeassistant.components.climate.const import (
|
||||
ATTR_PRESET_MODE,
|
||||
@@ -15,8 +17,12 @@ from homeassistant.components.climate.const import (
|
||||
PRESET_AWAY,
|
||||
PRESET_NONE,
|
||||
)
|
||||
from homeassistant.components.generic_thermostat import (
|
||||
DOMAIN as GENERIC_THERMOSTAT_DOMAIN,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
SERVICE_RELOAD,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
@@ -1246,3 +1252,41 @@ def _mock_restore_cache(hass, temperature=20, hvac_mode=HVAC_MODE_OFF):
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def test_reload(hass):
|
||||
"""Test we can reload."""
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
{
|
||||
"climate": {
|
||||
"platform": "generic_thermostat",
|
||||
"name": "test",
|
||||
"heater": "switch.any",
|
||||
"target_sensor": "sensor.any",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 1
|
||||
assert hass.states.get("climate.test") is not None
|
||||
|
||||
yaml_path = path.join(
|
||||
_get_fixtures_base_path(), "fixtures", "generic_thermostat/configuration.yaml",
|
||||
)
|
||||
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
|
||||
await hass.services.async_call(
|
||||
GENERIC_THERMOSTAT_DOMAIN, SERVICE_RELOAD, {}, blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_all()) == 1
|
||||
assert hass.states.get("climate.test") is None
|
||||
assert hass.states.get("climate.reload")
|
||||
|
||||
|
||||
def _get_fixtures_base_path():
|
||||
return path.dirname(path.dirname(path.dirname(__file__)))
|
||||
|
||||
Reference in New Issue
Block a user