mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Allow passing version to ConfigEntry.async_update_entry (#110077)
Allow passing minor_version and version to ConfigEntry.async_update_entry
This commit is contained in:
parent
7caf78a926
commit
793b6aa97d
@ -1496,12 +1496,14 @@ class ConfigEntries:
|
|||||||
self,
|
self,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
*,
|
*,
|
||||||
unique_id: str | None | UndefinedType = UNDEFINED,
|
|
||||||
title: str | UndefinedType = UNDEFINED,
|
|
||||||
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
data: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||||
|
minor_version: int | UndefinedType = UNDEFINED,
|
||||||
options: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
options: Mapping[str, Any] | UndefinedType = UNDEFINED,
|
||||||
pref_disable_new_entities: bool | UndefinedType = UNDEFINED,
|
pref_disable_new_entities: bool | UndefinedType = UNDEFINED,
|
||||||
pref_disable_polling: bool | UndefinedType = UNDEFINED,
|
pref_disable_polling: bool | UndefinedType = UNDEFINED,
|
||||||
|
title: str | UndefinedType = UNDEFINED,
|
||||||
|
unique_id: str | None | UndefinedType = UNDEFINED,
|
||||||
|
version: int | UndefinedType = UNDEFINED,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Update a config entry.
|
"""Update a config entry.
|
||||||
|
|
||||||
@ -1522,9 +1524,11 @@ class ConfigEntries:
|
|||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
for attr, value in (
|
for attr, value in (
|
||||||
("title", title),
|
("minor_version", minor_version),
|
||||||
("pref_disable_new_entities", pref_disable_new_entities),
|
("pref_disable_new_entities", pref_disable_new_entities),
|
||||||
("pref_disable_polling", pref_disable_polling),
|
("pref_disable_polling", pref_disable_polling),
|
||||||
|
("title", title),
|
||||||
|
("version", version),
|
||||||
):
|
):
|
||||||
if value is UNDEFINED or getattr(entry, attr) == value:
|
if value is UNDEFINED or getattr(entry, attr) == value:
|
||||||
continue
|
continue
|
||||||
|
@ -3199,13 +3199,18 @@ async def test_updating_entry_with_and_without_changes(
|
|||||||
for change in (
|
for change in (
|
||||||
{"data": {"second": True, "third": 456}},
|
{"data": {"second": True, "third": 456}},
|
||||||
{"data": {"second": True}},
|
{"data": {"second": True}},
|
||||||
|
{"minor_version": 2},
|
||||||
{"options": {"hello": True}},
|
{"options": {"hello": True}},
|
||||||
{"pref_disable_new_entities": True},
|
{"pref_disable_new_entities": True},
|
||||||
{"pref_disable_polling": True},
|
{"pref_disable_polling": True},
|
||||||
{"title": "sometitle"},
|
{"title": "sometitle"},
|
||||||
{"unique_id": "abcd1234"},
|
{"unique_id": "abcd1234"},
|
||||||
|
{"version": 2},
|
||||||
):
|
):
|
||||||
assert manager.async_update_entry(entry, **change) is True
|
assert manager.async_update_entry(entry, **change) is True
|
||||||
|
key = next(iter(change))
|
||||||
|
value = next(iter(change.values()))
|
||||||
|
assert getattr(entry, key) == value
|
||||||
assert manager.async_update_entry(entry, **change) is False
|
assert manager.async_update_entry(entry, **change) is False
|
||||||
|
|
||||||
assert manager.async_entry_for_domain_unique_id("test", "abc123") is None
|
assert manager.async_entry_for_domain_unique_id("test", "abc123") is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user