Remove migration for tag (#132200)
parent
a661e60511
commit
0111205f81
|
@ -106,7 +106,6 @@ class TagStore(Store[collection.SerializedStorageCollection]):
|
||||||
for tag in data["items"]:
|
for tag in data["items"]:
|
||||||
# Copy name in tag store to the entity registry
|
# Copy name in tag store to the entity registry
|
||||||
_create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME))
|
_create_entry(entity_registry, tag[CONF_ID], tag.get(CONF_NAME))
|
||||||
tag["migrated"] = True
|
|
||||||
if old_major_version == 1 and old_minor_version < 3:
|
if old_major_version == 1 and old_minor_version < 3:
|
||||||
# Version 1.3 removes tag_id from the store
|
# Version 1.3 removes tag_id from the store
|
||||||
for tag in data["items"]:
|
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.
|
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
|
return {k: v for k, v in item.items() if k != CONF_NAME}
|
||||||
# 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}
|
|
||||||
|
|
||||||
|
|
||||||
class TagDictStorageCollectionWebsocket(
|
class TagDictStorageCollectionWebsocket(
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
'items': list([
|
'items': list([
|
||||||
dict({
|
dict({
|
||||||
'id': 'test tag id',
|
'id': 'test tag id',
|
||||||
'migrated': True,
|
|
||||||
'name': 'test tag name',
|
|
||||||
}),
|
}),
|
||||||
dict({
|
dict({
|
||||||
'device_id': 'some_scanner',
|
'device_id': 'some_scanner',
|
||||||
|
@ -23,3 +21,24 @@
|
||||||
'version': 1,
|
'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,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
|
|
@ -6,6 +6,7 @@ from typing import Any
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
from syrupy.filters import props
|
||||||
|
|
||||||
from homeassistant.components.tag import DOMAIN, _create_entry, async_scan_tag
|
from homeassistant.components.tag import DOMAIN, _create_entry, async_scan_tag
|
||||||
from homeassistant.const import CONF_NAME, STATE_UNKNOWN
|
from homeassistant.const import CONF_NAME, STATE_UNKNOWN
|
||||||
|
@ -165,7 +166,9 @@ async def test_tag_scanned(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
freezer: FrozenDateTimeFactory,
|
freezer: FrozenDateTimeFactory,
|
||||||
|
hass_storage: dict[str, Any],
|
||||||
storage_setup,
|
storage_setup,
|
||||||
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test scanning tags."""
|
"""Test scanning tags."""
|
||||||
assert await storage_setup()
|
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):
|
def track_changes(coll: collection.ObservableCollection):
|
||||||
"""Create helper to track changes in a collection."""
|
"""Create helper to track changes in a collection."""
|
||||||
|
|
Loading…
Reference in New Issue