mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Cleanup unnecessary pylance warnings (#93849)
This commit is contained in:
parent
b5f5e1c8c3
commit
204215e0f2
@ -263,49 +263,52 @@ async def test_node_status_sensor(
|
|||||||
hass: HomeAssistant, client, lock_id_lock_as_id150, integration
|
hass: HomeAssistant, client, lock_id_lock_as_id150, integration
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test node status sensor is created and gets updated on node state changes."""
|
"""Test node status sensor is created and gets updated on node state changes."""
|
||||||
NODE_STATUS_ENTITY = "sensor.z_wave_module_for_id_lock_150_and_101_node_status"
|
node_status_entity_id = "sensor.z_wave_module_for_id_lock_150_and_101_node_status"
|
||||||
node = lock_id_lock_as_id150
|
node = lock_id_lock_as_id150
|
||||||
ent_reg = er.async_get(hass)
|
ent_reg = er.async_get(hass)
|
||||||
entity_entry = ent_reg.async_get(NODE_STATUS_ENTITY)
|
entity_entry = ent_reg.async_get(node_status_entity_id)
|
||||||
|
|
||||||
assert not entity_entry.disabled
|
assert not entity_entry.disabled
|
||||||
assert entity_entry.entity_category is EntityCategory.DIAGNOSTIC
|
assert entity_entry.entity_category is EntityCategory.DIAGNOSTIC
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "alive"
|
assert hass.states.get(node_status_entity_id).state == "alive"
|
||||||
|
|
||||||
# Test transitions work
|
# Test transitions work
|
||||||
event = Event(
|
event = Event(
|
||||||
"dead", data={"source": "node", "event": "dead", "nodeId": node.node_id}
|
"dead", data={"source": "node", "event": "dead", "nodeId": node.node_id}
|
||||||
)
|
)
|
||||||
node.receive_event(event)
|
node.receive_event(event)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "dead"
|
assert hass.states.get(node_status_entity_id).state == "dead"
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).attributes[ATTR_ICON] == "mdi:robot-dead"
|
assert (
|
||||||
|
hass.states.get(node_status_entity_id).attributes[ATTR_ICON] == "mdi:robot-dead"
|
||||||
|
)
|
||||||
|
|
||||||
event = Event(
|
event = Event(
|
||||||
"wake up", data={"source": "node", "event": "wake up", "nodeId": node.node_id}
|
"wake up", data={"source": "node", "event": "wake up", "nodeId": node.node_id}
|
||||||
)
|
)
|
||||||
node.receive_event(event)
|
node.receive_event(event)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "awake"
|
assert hass.states.get(node_status_entity_id).state == "awake"
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).attributes[ATTR_ICON] == "mdi:eye"
|
assert hass.states.get(node_status_entity_id).attributes[ATTR_ICON] == "mdi:eye"
|
||||||
|
|
||||||
event = Event(
|
event = Event(
|
||||||
"sleep", data={"source": "node", "event": "sleep", "nodeId": node.node_id}
|
"sleep", data={"source": "node", "event": "sleep", "nodeId": node.node_id}
|
||||||
)
|
)
|
||||||
node.receive_event(event)
|
node.receive_event(event)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "asleep"
|
assert hass.states.get(node_status_entity_id).state == "asleep"
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).attributes[ATTR_ICON] == "mdi:sleep"
|
assert hass.states.get(node_status_entity_id).attributes[ATTR_ICON] == "mdi:sleep"
|
||||||
|
|
||||||
event = Event(
|
event = Event(
|
||||||
"alive", data={"source": "node", "event": "alive", "nodeId": node.node_id}
|
"alive", data={"source": "node", "event": "alive", "nodeId": node.node_id}
|
||||||
)
|
)
|
||||||
node.receive_event(event)
|
node.receive_event(event)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "alive"
|
assert hass.states.get(node_status_entity_id).state == "alive"
|
||||||
assert (
|
assert (
|
||||||
hass.states.get(NODE_STATUS_ENTITY).attributes[ATTR_ICON] == "mdi:heart-pulse"
|
hass.states.get(node_status_entity_id).attributes[ATTR_ICON]
|
||||||
|
== "mdi:heart-pulse"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Disconnect the client and make sure the entity is still available
|
# Disconnect the client and make sure the entity is still available
|
||||||
await client.disconnect()
|
await client.disconnect()
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state != STATE_UNAVAILABLE
|
assert hass.states.get(node_status_entity_id).state != STATE_UNAVAILABLE
|
||||||
|
|
||||||
# Assert a node status sensor entity is not created for the controller
|
# Assert a node status sensor entity is not created for the controller
|
||||||
driver = client.driver
|
driver = client.driver
|
||||||
@ -330,15 +333,15 @@ async def test_node_status_sensor_not_ready(
|
|||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test node status sensor is created and available if node is not ready."""
|
"""Test node status sensor is created and available if node is not ready."""
|
||||||
NODE_STATUS_ENTITY = "sensor.z_wave_module_for_id_lock_150_and_101_node_status"
|
node_status_entity_id = "sensor.z_wave_module_for_id_lock_150_and_101_node_status"
|
||||||
node = lock_id_lock_as_id150_not_ready
|
node = lock_id_lock_as_id150_not_ready
|
||||||
assert not node.ready
|
assert not node.ready
|
||||||
ent_reg = er.async_get(hass)
|
ent_reg = er.async_get(hass)
|
||||||
entity_entry = ent_reg.async_get(NODE_STATUS_ENTITY)
|
entity_entry = ent_reg.async_get(node_status_entity_id)
|
||||||
|
|
||||||
assert not entity_entry.disabled
|
assert not entity_entry.disabled
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY)
|
assert hass.states.get(node_status_entity_id)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "alive"
|
assert hass.states.get(node_status_entity_id).state == "alive"
|
||||||
|
|
||||||
# Mark node as ready
|
# Mark node as ready
|
||||||
event = Event(
|
event = Event(
|
||||||
@ -352,14 +355,14 @@ async def test_node_status_sensor_not_ready(
|
|||||||
)
|
)
|
||||||
node.receive_event(event)
|
node.receive_event(event)
|
||||||
assert node.ready
|
assert node.ready
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY)
|
assert hass.states.get(node_status_entity_id)
|
||||||
assert hass.states.get(NODE_STATUS_ENTITY).state == "alive"
|
assert hass.states.get(node_status_entity_id).state == "alive"
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_REFRESH_VALUE,
|
SERVICE_REFRESH_VALUE,
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: NODE_STATUS_ENTITY,
|
ATTR_ENTITY_ID: node_status_entity_id,
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user