Skip to content

Commit

Permalink
Increase test coverage in yale_smart_alarm (home-assistant#132650)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjohansson-ST authored Dec 9, 2024
1 parent f4e48c3 commit 4e2e661
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
17 changes: 12 additions & 5 deletions tests/components/yale_smart_alarm/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 18 additions & 2 deletions tests/components/yale_smart_alarm/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
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

Expand Down Expand Up @@ -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

0 comments on commit 4e2e661

Please sign in to comment.