hass-core/tests/components/zwave/test_init.py

52 lines
1.3 KiB
Python
Raw Normal View History

2017-02-13 08:54:11 -08:00
"""Tests for the Z-Wave init."""
import asyncio
import unittest
from collections import OrderedDict
2017-02-13 08:54:11 -08:00
from homeassistant.bootstrap import async_setup_component
from homeassistant.components.zwave import (
CONFIG_SCHEMA, CONF_DEVICE_CONFIG_GLOB)
2017-02-13 08:54:11 -08:00
@asyncio.coroutine
def test_valid_device_config(hass, mock_openzwave):
"""Test valid device config."""
2017-02-13 08:54:11 -08:00
device_config = {
'light.kitchen': {
'ignored': 'true'
}
}
result = yield from async_setup_component(hass, 'zwave', {
2017-02-13 08:54:11 -08:00
'zwave': {
'device_config': device_config
}})
assert result
2017-02-13 08:54:11 -08:00
@asyncio.coroutine
def test_invalid_device_config(hass, mock_openzwave):
"""Test invalid device config."""
device_config = {
'light.kitchen': {
'some_ignored': 'true'
}
2017-02-13 08:54:11 -08:00
}
result = yield from async_setup_component(hass, 'zwave', {
'zwave': {
'device_config': device_config
}})
2017-02-13 08:54:11 -08:00
assert not result
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)