1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Allow storing other items than untyped dict in StorageCollection (#90932)

Allow storing other items than untyped dict in StorageCollection
This commit is contained in:
Erik Montnemery
2023-04-06 16:57:00 +02:00
committed by GitHub
parent 8025fbf398
commit 59a02cd08c
18 changed files with 134 additions and 91 deletions

View File

@@ -82,7 +82,7 @@ class MockObservableCollection(collection.ObservableCollection):
return entity_class.from_storage(config)
class MockStorageCollection(collection.StorageCollection):
class MockStorageCollection(collection.DictStorageCollection):
"""Mock storage collection."""
async def _process_create_data(self, data: dict) -> dict:
@@ -96,9 +96,9 @@ class MockStorageCollection(collection.StorageCollection):
"""Suggest an ID based on the config."""
return info["name"]
async def _update_data(self, data: dict, update_data: dict) -> dict:
async def _update_data(self, item: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
return {**data, **update_data}
return {**item, **update_data}
def test_id_manager() -> None: