Increase test coverage in yale_smart_alarm (#132650)

This commit is contained in:
G Johansson 2024-12-09 13:52:51 +01:00 committed by GitHub
parent f4e48c31bd
commit 4e2e6619d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 7 deletions

View File

@ -455,10 +455,17 @@ async def test_options_flow(
assert result["type"] is FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( with patch(
result["flow_id"], "homeassistant.components.yale_smart_alarm.coordinator.YaleSmartAlarmClient",
user_input={"lock_code_digits": 6}, 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["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

View File

@ -8,8 +8,12 @@ import pytest
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from yalesmartalarmclient import YaleSmartAlarmData from yalesmartalarmclient import YaleSmartAlarmData
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SERVICE_TURN_OFF from homeassistant.components.switch import (
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, Platform 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.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@ -44,3 +48,15 @@ async def test_switch(
state = hass.states.get("switch.device1_autolock") state = hass.states.get("switch.device1_autolock")
assert state.state == STATE_OFF 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