2017-02-13 08:54:11 -08:00
|
|
|
"""Tests for the Z-Wave init."""
|
|
|
|
import asyncio
|
2017-04-07 08:39:35 +03:00
|
|
|
import unittest
|
|
|
|
from collections import OrderedDict
|
2017-02-13 08:54:11 -08:00
|
|
|
|
|
|
|
from homeassistant.bootstrap import async_setup_component
|
2017-04-07 08:39:35 +03:00
|
|
|
from homeassistant.components.zwave import (
|
|
|
|
CONFIG_SCHEMA, CONF_DEVICE_CONFIG_GLOB)
|
2017-02-13 08:54:11 -08:00
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
2017-03-09 05:35:04 -08:00
|
|
|
def test_valid_device_config(hass, mock_openzwave):
|
2017-02-23 23:06:28 +02:00
|
|
|
"""Test valid device config."""
|
2017-02-13 08:54:11 -08:00
|
|
|
device_config = {
|
|
|
|
'light.kitchen': {
|
|
|
|
'ignored': 'true'
|
|
|
|
}
|
|
|
|
}
|
2017-02-23 23:06:28 +02:00
|
|
|
result = yield from async_setup_component(hass, 'zwave', {
|
2017-02-13 08:54:11 -08:00
|
|
|
'zwave': {
|
|
|
|
'device_config': device_config
|
|
|
|
}})
|
|
|
|
|
2017-02-23 23:06:28 +02:00
|
|
|
assert result
|
2017-02-13 08:54:11 -08:00
|
|
|
|
2017-02-23 23:06:28 +02:00
|
|
|
|
|
|
|
@asyncio.coroutine
|
2017-03-09 05:35:04 -08:00
|
|
|
def test_invalid_device_config(hass, mock_openzwave):
|
2017-02-23 23:06:28 +02:00
|
|
|
"""Test invalid device config."""
|
|
|
|
device_config = {
|
|
|
|
'light.kitchen': {
|
|
|
|
'some_ignored': 'true'
|
|
|
|
}
|
2017-02-13 08:54:11 -08:00
|
|
|
}
|
2017-02-23 23:06:28 +02:00
|
|
|
result = yield from async_setup_component(hass, 'zwave', {
|
|
|
|
'zwave': {
|
|
|
|
'device_config': device_config
|
|
|
|
}})
|
2017-02-13 08:54:11 -08:00
|
|
|
|
2017-02-23 23:06:28 +02:00
|
|
|
assert not result
|
2017-04-07 08:39:35 +03:00
|
|
|
|
|
|
|
|
|
|
|
class TestZwave(unittest.TestCase):
|
|
|
|
"""Test zwave init."""
|
|
|
|
|
|
|
|
def test_device_config_glob_is_ordered(self):
|
|
|
|
"""Test that device_config_glob preserves order."""
|
|
|
|
conf = CONFIG_SCHEMA(
|
|
|
|
{'zwave': {CONF_DEVICE_CONFIG_GLOB: OrderedDict()}})
|
|
|
|
self.assertIsInstance(
|
|
|
|
conf['zwave'][CONF_DEVICE_CONFIG_GLOB], OrderedDict)
|