2017-02-13 08:54:11 -08:00
|
|
|
"""Tests for the Z-Wave init."""
|
|
|
|
import asyncio
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from homeassistant.bootstrap import async_setup_component
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def mock_openzwave():
|
|
|
|
"""Mock out Open Z-Wave."""
|
|
|
|
libopenzwave = MagicMock()
|
|
|
|
libopenzwave.__file__ = 'test'
|
|
|
|
with patch.dict('sys.modules', {
|
|
|
|
'libopenzwave': libopenzwave,
|
|
|
|
'openzwave.option': MagicMock(),
|
|
|
|
'openzwave.network': MagicMock(),
|
|
|
|
'openzwave.group': MagicMock(),
|
|
|
|
}):
|
|
|
|
yield
|
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
2017-02-23 23:06:28 +02:00
|
|
|
def test_valid_device_config(hass):
|
|
|
|
"""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
|
|
|
|
def test_invalid_device_config(hass):
|
|
|
|
"""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
|