mirror of https://github.com/home-assistant/core
61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
"""Tests for the venstar integration."""
|
|
|
|
import requests_mock
|
|
|
|
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
|
from homeassistant.const import CONF_HOST, CONF_PLATFORM
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
from tests.common import load_fixture
|
|
|
|
TEST_MODELS = ["t2k", "colortouch"]
|
|
|
|
|
|
def mock_venstar_devices(f):
|
|
"""Decorate function to mock a Venstar Colortouch and T2000 thermostat API."""
|
|
|
|
async def wrapper(hass: HomeAssistant) -> None:
|
|
# Mock thermostats are:
|
|
# Venstar T2000, FW 4.38
|
|
# Venstar "colortouch" T7850, FW 5.1
|
|
with requests_mock.mock() as m:
|
|
for model in TEST_MODELS:
|
|
m.get(
|
|
f"http://venstar-{model}.localdomain/",
|
|
text=load_fixture(f"venstar/{model}_root.json"),
|
|
)
|
|
m.get(
|
|
f"http://venstar-{model}.localdomain/query/info",
|
|
text=load_fixture(f"venstar/{model}_info.json"),
|
|
)
|
|
m.get(
|
|
f"http://venstar-{model}.localdomain/query/sensors",
|
|
text=load_fixture(f"venstar/{model}_sensors.json"),
|
|
)
|
|
m.get(
|
|
f"http://venstar-{model}.localdomain/query/alerts",
|
|
text=load_fixture(f"venstar/{model}_alerts.json"),
|
|
)
|
|
await f(hass)
|
|
|
|
return wrapper
|
|
|
|
|
|
async def async_init_integration(
|
|
hass: HomeAssistant,
|
|
skip_setup: bool = False,
|
|
):
|
|
"""Set up the venstar integration in Home Assistant."""
|
|
platform_config = [
|
|
{
|
|
CONF_PLATFORM: "venstar",
|
|
CONF_HOST: f"venstar-{model}.localdomain",
|
|
}
|
|
for model in TEST_MODELS
|
|
]
|
|
config = {CLIMATE_DOMAIN: platform_config}
|
|
|
|
await async_setup_component(hass, CLIMATE_DOMAIN, config)
|
|
await hass.async_block_till_done()
|