|
|
@@ -174,6 +174,68 @@ async def test_options_group_dropped_when_all_its_locks_removed(hass):
|
|
|
assert entry.options[CONF_GROUPS] == []
|
|
|
|
|
|
|
|
|
+async def test_options_edit_group_single_group_skips_selection(hass):
|
|
|
+ entry = _entry_with_group()
|
|
|
+ await _setup_entry(hass, entry)
|
|
|
+
|
|
|
+ result = await _begin_options(hass, entry, "edit_group")
|
|
|
+ assert result["type"] is FlowResultType.FORM
|
|
|
+ assert result["step_id"] == "edit_group_locks"
|
|
|
+
|
|
|
+ result = await hass.config_entries.options.async_configure(
|
|
|
+ result["flow_id"], {CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID]}
|
|
|
+ )
|
|
|
+ assert result["type"] is FlowResultType.MENU
|
|
|
+ result = await _finish(hass, result["flow_id"])
|
|
|
+
|
|
|
+ assert result["type"] is FlowResultType.CREATE_ENTRY
|
|
|
+ assert entry.options[CONF_GROUPS] == [
|
|
|
+ {CONF_GROUP_NAME: "All Locks", CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID]}
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+async def test_options_edit_group_multiple_groups_prompts_for_selection(hass):
|
|
|
+ entry = MockConfigEntry(
|
|
|
+ domain=DOMAIN,
|
|
|
+ data={CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID, LOCK_2]},
|
|
|
+ options={
|
|
|
+ CONF_GROUPS: [
|
|
|
+ {CONF_GROUP_NAME: "All Locks", CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID, LOCK_2]},
|
|
|
+ {CONF_GROUP_NAME: "Front only", CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID]},
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ entry_id="test_entry_edit_group",
|
|
|
+ )
|
|
|
+ await _setup_entry(hass, entry)
|
|
|
+
|
|
|
+ result = await _begin_options(hass, entry, "edit_group")
|
|
|
+ assert result["type"] is FlowResultType.FORM
|
|
|
+ assert result["step_id"] == "edit_group"
|
|
|
+
|
|
|
+ result = await hass.config_entries.options.async_configure(
|
|
|
+ result["flow_id"], {"group": "Front only"}
|
|
|
+ )
|
|
|
+ assert result["type"] is FlowResultType.FORM
|
|
|
+ assert result["step_id"] == "edit_group_locks"
|
|
|
+
|
|
|
+ result = await hass.config_entries.options.async_configure(
|
|
|
+ result["flow_id"], {CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID, LOCK_2]}
|
|
|
+ )
|
|
|
+ result = await _finish(hass, result["flow_id"])
|
|
|
+
|
|
|
+ assert entry.options[CONF_GROUPS] == [
|
|
|
+ {CONF_GROUP_NAME: "All Locks", CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID, LOCK_2]},
|
|
|
+ {CONF_GROUP_NAME: "Front only", CONF_LOCK_ENTITY_IDS: [LOCK_ENTITY_ID, LOCK_2]},
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+async def test_options_edit_group_no_groups_returns_to_menu(hass, config_entry):
|
|
|
+ await _setup_entry(hass, config_entry)
|
|
|
+
|
|
|
+ result = await _begin_options(hass, config_entry, "edit_group")
|
|
|
+ assert result["type"] is FlowResultType.MENU
|
|
|
+
|
|
|
+
|
|
|
async def test_options_abandoned_flow_changes_nothing(hass):
|
|
|
"""Lock changes are staged on the flow; without 'finish' the entry is untouched."""
|
|
|
entry = _entry_with_group()
|