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:
parent
c717fd19de
commit
d4c28e04e4
8 changed files with 160 additions and 28 deletions
|
@ -1,5 +1,11 @@
|
|||
"""Test the Z-Wave JS cover platform."""
|
||||
from zwave_js_server.const import (
|
||||
CURRENT_STATE_PROPERTY,
|
||||
CURRENT_VALUE_PROPERTY,
|
||||
CommandClass,
|
||||
)
|
||||
from zwave_js_server.event import Event
|
||||
from zwave_js_server.model.node import Node
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
|
@ -9,6 +15,7 @@ from homeassistant.components.cover import (
|
|||
SERVICE_OPEN_COVER,
|
||||
CoverDeviceClass,
|
||||
)
|
||||
from homeassistant.components.zwave_js.helpers import ZwaveValueMatcher
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
STATE_CLOSED,
|
||||
|
@ -18,6 +25,8 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN,
|
||||
)
|
||||
|
||||
from .common import replace_value_of_zwave_value
|
||||
|
||||
WINDOW_COVER_ENTITY = "cover.zws_12"
|
||||
GDC_COVER_ENTITY = "cover.aeon_labs_garage_door_controller_gen5"
|
||||
BLIND_COVER_ENTITY = "cover.window_blind_controller"
|
||||
|
@ -600,3 +609,59 @@ async def test_motor_barrier_cover(hass, client, gdc_zw062, integration):
|
|||
|
||||
state = hass.states.get(GDC_COVER_ENTITY)
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
|
||||
async def test_motor_barrier_cover_no_primary_value(
|
||||
hass, client, gdc_zw062_state, integration
|
||||
):
|
||||
"""Test the cover entity where primary value value is None."""
|
||||
node_state = replace_value_of_zwave_value(
|
||||
gdc_zw062_state,
|
||||
[
|
||||
ZwaveValueMatcher(
|
||||
property_=CURRENT_STATE_PROPERTY,
|
||||
command_class=CommandClass.BARRIER_OPERATOR,
|
||||
)
|
||||
],
|
||||
None,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(GDC_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.GARAGE
|
||||
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert ATTR_CURRENT_POSITION not in state.attributes
|
||||
|
||||
|
||||
async def test_fibaro_FGR222_shutter_cover_no_tilt(
|
||||
hass, client, fibaro_fgr222_shutter_state, integration
|
||||
):
|
||||
"""Test tilt function of the Fibaro Shutter devices with tilt value is None."""
|
||||
node_state = replace_value_of_zwave_value(
|
||||
fibaro_fgr222_shutter_state,
|
||||
[
|
||||
ZwaveValueMatcher(
|
||||
property_="fibaro",
|
||||
command_class=CommandClass.MANUFACTURER_PROPRIETARY,
|
||||
property_key="venetianBlindsTilt",
|
||||
),
|
||||
ZwaveValueMatcher(
|
||||
property_=CURRENT_VALUE_PROPERTY,
|
||||
command_class=CommandClass.SWITCH_MULTILEVEL,
|
||||
),
|
||||
],
|
||||
None,
|
||||
)
|
||||
node = Node(client, node_state)
|
||||
client.driver.controller.emit("node added", {"node": node})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get(FIBARO_SHUTTER_COVER_ENTITY)
|
||||
assert state
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert ATTR_CURRENT_POSITION not in state.attributes
|
||||
assert ATTR_CURRENT_TILT_POSITION not in state.attributes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue