mirror of
https://github.com/home-assistant/core.git
synced 2026-05-04 11:54:35 +02:00
Add zwave application version (#26205)
* Set application version in zwave * update tests for more coverage
This commit is contained in:
committed by
Martin Hjelmare
parent
a4fd991ab5
commit
5d5102e1a2
@@ -164,6 +164,73 @@ async def test_central_scene_activated(hass, mock_openzwave):
|
||||
assert events[0].data[const.ATTR_SCENE_DATA] == scene_data
|
||||
|
||||
|
||||
async def test_application_version(hass, mock_openzwave):
|
||||
"""Test application version."""
|
||||
mock_receivers = {}
|
||||
|
||||
signal_mocks = [
|
||||
mock_zwave.MockNetwork.SIGNAL_VALUE_CHANGED,
|
||||
mock_zwave.MockNetwork.SIGNAL_VALUE_ADDED,
|
||||
]
|
||||
|
||||
def mock_connect(receiver, signal, *args, **kwargs):
|
||||
if signal in signal_mocks:
|
||||
mock_receivers[signal] = receiver
|
||||
|
||||
node = mock_zwave.MockNode(node_id=11)
|
||||
|
||||
with patch("pydispatch.dispatcher.connect", new=mock_connect):
|
||||
entity = node_entity.ZWaveNodeEntity(node, mock_openzwave)
|
||||
|
||||
for signal_mock in signal_mocks:
|
||||
assert signal_mock in mock_receivers.keys()
|
||||
|
||||
events = []
|
||||
|
||||
def listener(event):
|
||||
events.append(event)
|
||||
|
||||
# Make sure application version isn't set before
|
||||
assert (
|
||||
node_entity.ATTR_APPLICATION_VERSION
|
||||
not in entity.device_state_attributes.keys()
|
||||
)
|
||||
|
||||
# Add entity to hass
|
||||
entity.hass = hass
|
||||
entity.entity_id = "zwave.mock_node"
|
||||
|
||||
# Fire off an added value
|
||||
value = mock_zwave.MockValue(
|
||||
command_class=const.COMMAND_CLASS_VERSION,
|
||||
label="Application Version",
|
||||
data="5.10",
|
||||
)
|
||||
hass.async_add_job(
|
||||
mock_receivers[mock_zwave.MockNetwork.SIGNAL_VALUE_ADDED], node, value
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
entity.device_state_attributes[node_entity.ATTR_APPLICATION_VERSION] == "5.10"
|
||||
)
|
||||
|
||||
# Fire off a changed
|
||||
value = mock_zwave.MockValue(
|
||||
command_class=const.COMMAND_CLASS_VERSION,
|
||||
label="Application Version",
|
||||
data="4.14",
|
||||
)
|
||||
hass.async_add_job(
|
||||
mock_receivers[mock_zwave.MockNetwork.SIGNAL_VALUE_CHANGED], node, value
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
entity.device_state_attributes[node_entity.ATTR_APPLICATION_VERSION] == "4.14"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("mock_openzwave")
|
||||
class TestZWaveNodeEntity(unittest.TestCase):
|
||||
"""Class to test ZWaveNodeEntity."""
|
||||
|
||||
Reference in New Issue
Block a user