hass-core/tests/components/zwave/test_init.py
Andrey f96e06a2c2 Preserve customize glob order. (#6963)
* Preserve customize glob order.

* add tests
2017-04-06 22:39:35 -07:00

51 lines
1.3 KiB
Python

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