From 4e2e6619d0d7766ff9c7104a48dc5090f8f1f9ff Mon Sep 17 00:00:00 2001 From: G Johansson Date: Mon, 9 Dec 2024 13:52:51 +0100 Subject: [PATCH] Increase test coverage in yale_smart_alarm (#132650) --- .../yale_smart_alarm/test_config_flow.py | 17 +++++++++++----- .../yale_smart_alarm/test_switch.py | 20 +++++++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/tests/components/yale_smart_alarm/test_config_flow.py b/tests/components/yale_smart_alarm/test_config_flow.py index 51106751f03..0b008d4c696 100644 --- a/tests/components/yale_smart_alarm/test_config_flow.py +++ b/tests/components/yale_smart_alarm/test_config_flow.py @@ -455,10 +455,17 @@ async def test_options_flow( assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" - result = await hass.config_entries.options.async_configure( - result["flow_id"], - user_input={"lock_code_digits": 6}, - ) + with patch( + "homeassistant.components.yale_smart_alarm.coordinator.YaleSmartAlarmClient", + return_value=load_config_entry[1], + ): + result = await hass.config_entries.options.async_configure( + result["flow_id"], + user_input={"lock_code_digits": 4}, + ) + await hass.async_block_till_done() assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["data"] == {"lock_code_digits": 6} + assert result["data"] == {"lock_code_digits": 4} + + assert entry.state == config_entries.ConfigEntryState.LOADED diff --git a/tests/components/yale_smart_alarm/test_switch.py b/tests/components/yale_smart_alarm/test_switch.py index b189a3fd003..369f8f8f10c 100644 --- a/tests/components/yale_smart_alarm/test_switch.py +++ b/tests/components/yale_smart_alarm/test_switch.py @@ -8,8 +8,12 @@ import pytest from syrupy.assertion import SnapshotAssertion from yalesmartalarmclient import YaleSmartAlarmData -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SERVICE_TURN_OFF -from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, Platform +from homeassistant.components.switch import ( + DOMAIN as SWITCH_DOMAIN, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, +) +from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -44,3 +48,15 @@ async def test_switch( state = hass.states.get("switch.device1_autolock") assert state.state == STATE_OFF + + await hass.services.async_call( + SWITCH_DOMAIN, + SERVICE_TURN_ON, + { + ATTR_ENTITY_ID: "switch.device1_autolock", + }, + blocking=True, + ) + + state = hass.states.get("switch.device1_autolock") + assert state.state == STATE_ON