ZWave switch tests (#6722)
parent
dddbce82f5
commit
866bf887d3
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue