Reduce missed coverage in zwave_js (#79571)

* Reduce missed coverage in zwave_js.climate and cover

* Add switch platform coverage

* Add select platform

* Add lock platform

* Remove one line of coverage from number platform

* update docstring
This commit is contained in:
Raman Gupta
2022-10-18 04:06:29 -04:00
committed by GitHub
parent c717fd19de
commit d4c28e04e4
8 changed files with 160 additions and 28 deletions

View File

@@ -1,11 +1,14 @@
"""Test the Z-Wave JS switch platform."""
from zwave_js_server.const import CURRENT_VALUE_PROPERTY, CommandClass
from zwave_js_server.event import Event
from zwave_js_server.model.node import Node
from homeassistant.components.switch import DOMAIN, SERVICE_TURN_OFF, SERVICE_TURN_ON
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNKNOWN
from .common import SWITCH_ENTITY
from .common import SWITCH_ENTITY, replace_value_of_zwave_value
async def test_switch(hass, hank_binary_switch, integration, client):
@@ -14,7 +17,7 @@ async def test_switch(hass, hank_binary_switch, integration, client):
node = hank_binary_switch
assert state
assert state.state == "off"
assert state.state == STATE_OFF
# Test turning on
await hass.services.async_call(
@@ -178,3 +181,25 @@ async def test_barrier_signaling_switch(hass, gdc_zw062, integration, client):
state = hass.states.get(entity)
assert state.state == STATE_ON
async def test_switch_no_value(hass, hank_binary_switch_state, integration, client):
"""Test the switch where primary value value is None."""
node_state = replace_value_of_zwave_value(
hank_binary_switch_state,
[
ZwaveValueMatcher(
property_=CURRENT_VALUE_PROPERTY,
command_class=CommandClass.SWITCH_BINARY,
)
],
None,
)
node = Node(client, node_state)
client.driver.controller.emit("node added", {"node": node})
await hass.async_block_till_done()
state = hass.states.get(SWITCH_ENTITY)
assert state
assert state.state == STATE_UNKNOWN