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

deCONZ - Support Symfonisk sound controller with device triggers (#26913)

* Device trigger tests shall use the common gateway mock

* Follow ebaauws clarification of signals

* Fix translations
This commit is contained in:
Robert Svensson
2019-10-02 22:12:59 +02:00
committed by GitHub
parent 09c5b9feb3
commit d8c6b281b8
4 changed files with 24 additions and 49 deletions

View File

@@ -1,30 +1,13 @@
"""deCONZ device automation tests."""
from asynctest import patch
from copy import deepcopy
from homeassistant import config_entries
from homeassistant.components import deconz
from homeassistant.components.deconz import device_trigger
from tests.common import async_get_device_automations
BRIDGEID = "0123456789"
from .test_gateway import ENTRY_CONFIG, DECONZ_WEB_REQUEST, setup_deconz_integration
ENTRY_CONFIG = {
deconz.config_flow.CONF_API_KEY: "ABCDEF",
deconz.config_flow.CONF_BRIDGEID: BRIDGEID,
deconz.config_flow.CONF_HOST: "1.2.3.4",
deconz.config_flow.CONF_PORT: 80,
}
DECONZ_CONFIG = {
"bridgeid": BRIDGEID,
"mac": "00:11:22:33:44:55",
"name": "deCONZ mock gateway",
"sw_version": "2.05.69",
"websocketport": 1234,
}
DECONZ_SENSOR = {
SENSORS = {
"1": {
"config": {
"alert": "none",
@@ -46,37 +29,14 @@ DECONZ_SENSOR = {
}
}
DECONZ_WEB_REQUEST = {"config": DECONZ_CONFIG, "sensors": DECONZ_SENSOR}
async def setup_deconz(hass, options):
"""Create the deCONZ gateway."""
config_entry = config_entries.ConfigEntry(
version=1,
domain=deconz.DOMAIN,
title="Mock Title",
data=ENTRY_CONFIG,
source="test",
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
system_options={},
options=options,
entry_id="1",
)
with patch(
"pydeconz.DeconzSession.async_get_state", return_value=DECONZ_WEB_REQUEST
):
await deconz.async_setup_entry(hass, config_entry)
await hass.async_block_till_done()
hass.config_entries._entries.append(config_entry)
return hass.data[deconz.DOMAIN][BRIDGEID]
async def test_get_triggers(hass):
"""Test triggers work."""
gateway = await setup_deconz(hass, options={})
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
gateway = await setup_deconz_integration(
hass, ENTRY_CONFIG, options={}, get_state_response=data
)
device_id = gateway.events[0].device_id
triggers = await async_get_device_automations(hass, "trigger", device_id)