Create zwave devices on OZW thread and only add them during discovery (#6096)
* Create zwave devices on OZW thread and only add them during discovery. * Read and write devices dict from loop thread. * More async * replace callback with coroutine * import common function instead of callin git
This commit is contained in:
parent
f2a2d6bfa1
commit
1d32bced1c
10 changed files with 114 additions and 130 deletions
|
@ -5,8 +5,6 @@ from unittest.mock import MagicMock, patch
|
|||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components.zwave import (
|
||||
DATA_DEVICE_CONFIG, DEVICE_CONFIG_SCHEMA_ENTRY)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
@ -24,24 +22,32 @@ def mock_openzwave():
|
|||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_device_config(hass):
|
||||
"""Test device config stored in hass."""
|
||||
def test_valid_device_config(hass):
|
||||
"""Test valid device config."""
|
||||
device_config = {
|
||||
'light.kitchen': {
|
||||
'ignored': 'true'
|
||||
}
|
||||
}
|
||||
yield from async_setup_component(hass, 'zwave', {
|
||||
result = yield from async_setup_component(hass, 'zwave', {
|
||||
'zwave': {
|
||||
'device_config': device_config
|
||||
}})
|
||||
|
||||
assert DATA_DEVICE_CONFIG in hass.data
|
||||
assert result
|
||||
|
||||
test_data = {
|
||||
key: DEVICE_CONFIG_SCHEMA_ENTRY(value)
|
||||
for key, value in device_config.items()
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_invalid_device_config(hass):
|
||||
"""Test invalid device config."""
|
||||
device_config = {
|
||||
'light.kitchen': {
|
||||
'some_ignored': 'true'
|
||||
}
|
||||
}
|
||||
result = yield from async_setup_component(hass, 'zwave', {
|
||||
'zwave': {
|
||||
'device_config': device_config
|
||||
}})
|
||||
|
||||
assert hass.data[DATA_DEVICE_CONFIG].get('light.kitchen') == \
|
||||
test_data.get('light.kitchen')
|
||||
assert not result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue