Review fixes: persisted flow-user admin seed and real cv.multi_select
Review rounds 1-2 (Codex gpt-5.6-terra) found two HIGHs against real HA: - entry.context is not a durable record — the config flow now persists the completing HA user into entry data (CONF_ADMIN_USER_IDS) and the seed precedence becomes: options copy (the current list) first, then the config flow's entry-data copy, then the context user as a last resort. Config-flow tests cover the persisted user and the context-free path; a seed-precedence test covers options > data. - the hand-rolled closure could not serialize as an HA multi-select. The harness now mocks homeassistant.helpers.config_validation with a faithful multi_select, and the flow uses cv.multi_select exactly as real HA code does. Suite: 904 passed.
This commit is contained in:
@@ -278,3 +278,27 @@ async def test_setup_does_not_reseed_narrowed_allowlist(
|
||||
finally:
|
||||
await database.close()
|
||||
assert await async_unload_entry(hass, entry_reloaded) is True
|
||||
|
||||
|
||||
async def test_setup_seed_prefers_options_over_entry_data(
|
||||
hass, make_entry
|
||||
) -> None:
|
||||
"""Seed precedence on a fresh database: the options flow's saved
|
||||
list (the current one) beats the config flow's original copy."""
|
||||
from custom_components.nestquest.const import CONF_ADMIN_USER_IDS
|
||||
|
||||
entry = await _setup_entry(
|
||||
hass,
|
||||
make_entry(
|
||||
options={CONF_ADMIN_USER_IDS: ["user-current"]},
|
||||
data={CONF_ADMIN_USER_IDS: ["ha-owner"]},
|
||||
context={"user_id": "ha-owner"},
|
||||
),
|
||||
hass.registry,
|
||||
)
|
||||
database = entry.runtime_data.database
|
||||
try:
|
||||
assert await list_admin_ids(database) == ["user-current"]
|
||||
finally:
|
||||
await database.close()
|
||||
assert await async_unload_entry(hass, entry) is True
|
||||
|
||||
Reference in New Issue
Block a user