fix: the deprecated listener+reload combo is gone — reauth uses async_update_reload_and_abort(_get_reauth_entry()), zeroconf host update is update-only, the __init__ options-reload listener is removed (grep-pinned); host-change tests assert update-without-reload (t29 G3a)
This commit is contained in:
1 parent
3e0208789a
commit
bcb8b962e7
6 files changed
+158
-50
No files matched your search
+29
-1
@@ -122,13 +122,41 @@ def install() -> None:
|
||||
|
||||
config_entries = types.ModuleType("homeassistant.config_entries")
|
||||
config_entries.ConfigEntry = type("ConfigEntry", (), {})
|
||||
class _ConfigFlowStub:
|
||||
"""ConfigFlow shape used by flow tests (t29 G3a API included)."""
|
||||
|
||||
def _get_reauth_entry(self, entry=None):
|
||||
if entry is not None:
|
||||
return entry
|
||||
return None # the caller's cached entry is used
|
||||
|
||||
# NOTE: the real HA signature is async_update_reload_and_abort(entry, ...)
|
||||
# which updates, schedules the reload and aborts; the stub records both.
|
||||
|
||||
def async_update_reload_and_abort(self, entry, **kwargs):
|
||||
updates = kwargs.get("options_updates") or kwargs.get("data_updates") or {}
|
||||
for key, value in updates.items():
|
||||
if key in ("options", "data", "unique_id"):
|
||||
setattr(entry, key, value)
|
||||
else:
|
||||
getattr(entry, "options", {}).setdefault(key, value) # best effort
|
||||
reload_scheduler = getattr(self.hass, "scheduled_reloads", None)
|
||||
if reload_scheduler is not None:
|
||||
reload_scheduler.append(entry.entry_id)
|
||||
return {"type": "abort", "reason": "reauth_successful"}
|
||||
|
||||
def _config_flow_init(self, *args, **kwargs):
|
||||
self.context = getattr(self, "context", {}) or {}
|
||||
self.hass = getattr(self, "hass", None)
|
||||
|
||||
_config_flow_base = type(
|
||||
"ConfigFlow",
|
||||
(),
|
||||
(_ConfigFlowStub,),
|
||||
{
|
||||
"__init_subclass__": classmethod(
|
||||
lambda cls, domain=None, **kwargs: None
|
||||
),
|
||||
"__init__": _config_flow_init,
|
||||
},
|
||||
)
|
||||
config_entries.ConfigFlow = _config_flow_base
|
||||
|
||||
Reference in new issue
Block a user