Remove migration for tag (#132200)

pull/132514/head
G Johansson 2024-12-06 20:54:05 +01:00 committed by GitHub
parent a661e60511
commit 0111205f81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 7 deletions

View File

@ -106,7 +106,6 @@ class TagStore(Store[collection.SerializedStorageCollection]):
for tag in data["items"]:
# Copy name in tag store to the entity registry
_create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME))
tag["migrated"] = True
if old_major_version == 1 and old_minor_version < 3:
# Version 1.3 removes tag_id from the store
for tag in data["items"]:
@ -178,10 +177,7 @@ class TagStorageCollection(collection.DictStorageCollection):
We don't store the name, it's stored in the entity registry.
"""
# Preserve the name of migrated entries to allow downgrading to 2024.5
# without losing tag names. This can be removed in HA Core 2025.1.
migrated = item_id in self.data and "migrated" in self.data[item_id]
return {k: v for k, v in item.items() if k != CONF_NAME or migrated}
return {k: v for k, v in item.items() if k != CONF_NAME}
class TagDictStorageCollectionWebsocket(

View File

@ -5,8 +5,6 @@
'items': list([
dict({
'id': 'test tag id',
'migrated': True,
'name': 'test tag name',
}),
dict({
'device_id': 'some_scanner',
@ -23,3 +21,24 @@
'version': 1,
})
# ---
# name: test_tag_scanned
dict({
'data': dict({
'items': list([
dict({
'id': 'test tag id',
}),
dict({
'id': 'test tag id 2',
}),
dict({
'device_id': 'some_scanner',
'id': 'new tag',
}),
]),
}),
'key': 'tag',
'minor_version': 3,
'version': 1,
})
# ---

View File

@ -6,6 +6,7 @@ from typing import Any
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy import SnapshotAssertion
from syrupy.filters import props
from homeassistant.components.tag import DOMAIN, _create_entry, async_scan_tag
from homeassistant.const import CONF_NAME, STATE_UNKNOWN
@ -165,7 +166,9 @@ async def test_tag_scanned(
hass: HomeAssistant,
hass_ws_client: WebSocketGenerator,
freezer: FrozenDateTimeFactory,
hass_storage: dict[str, Any],
storage_setup,
snapshot: SnapshotAssertion,
) -> None:
"""Test scanning tags."""
assert await storage_setup()
@ -205,6 +208,12 @@ async def test_tag_scanned(
},
]
# Trigger store
freezer.tick(11)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert hass_storage[DOMAIN] == snapshot(exclude=props("last_scanned"))
def track_changes(coll: collection.ObservableCollection):
"""Create helper to track changes in a collection."""