ZWave switch tests (#6722)

pull/2675/merge
Adam Mills 2017-03-20 13:17:42 -04:00 committed by GitHub
parent dddbce82f5
commit 866bf887d3
2 changed files with 29 additions and 1 deletions

View File

@ -421,7 +421,6 @@ omit =
homeassistant/components/switch/tplink.py
homeassistant/components/switch/transmission.py
homeassistant/components/switch/wake_on_lan.py
homeassistant/components/switch/zwave.py
homeassistant/components/telegram_webhooks.py
homeassistant/components/thingspeak.py
homeassistant/components/tts/amazon_polly.py

View File

@ -1,4 +1,6 @@
"""Test Z-Wave switches."""
from unittest.mock import patch
from homeassistant.components.switch import zwave
from tests.mock.zwave import (
@ -51,3 +53,30 @@ def test_switch_value_changed(mock_openzwave):
value_changed(value)
assert device.is_on
@patch('time.perf_counter')
def test_switch_refresh_on_update(mock_counter, mock_openzwave):
"""Test value changed for refresh on update Z-Wave switch."""
mock_counter.return_value = 10
node = MockNode(manufacturer_id='013c', product_type='0001',
product_id='0005')
value = MockValue(data=False, node=node)
values = MockEntityValues(primary=value)
device = zwave.get_device(node=node, values=values, node_config={})
assert not device.is_on
mock_counter.return_value = 15
value.data = True
value_changed(value)
assert device.is_on
assert not node.request_state.called
mock_counter.return_value = 45
value.data = False
value_changed(value)
assert not device.is_on
assert node.request_state.called