Remove old migration from lovelace (#113388)

This commit is contained in:
Erik Montnemery 2024-03-14 10:43:55 +01:00 committed by GitHub
parent 7ae852e5ed
commit 9eea786411
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 72 deletions

View file

@ -232,23 +232,6 @@ class DashboardsCollection(collection.DictStorageCollection):
storage.Store(hass, DASHBOARDS_STORAGE_VERSION, DASHBOARDS_STORAGE_KEY),
)
async def _async_load_data(self) -> collection.SerializedStorageCollection | None:
"""Load the data."""
if (data := await self.store.async_load()) is None:
return data
updated = False
for item in data["items"] or []:
if "-" not in item[CONF_URL_PATH]:
updated = True
item[CONF_URL_PATH] = f"lovelace-{item[CONF_URL_PATH]}"
if updated:
await self.store.async_save(data)
return data
async def _process_create_data(self, data: dict) -> dict:
"""Validate the config is valid."""
if "-" not in data[CONF_URL_PATH]:

View file

@ -441,61 +441,6 @@ async def test_storage_dashboards(
assert dashboard.CONFIG_STORAGE_KEY.format(dashboard_id) not in hass_storage
async def test_storage_dashboard_migrate(
hass: HomeAssistant, hass_ws_client, hass_storage: dict[str, Any]
) -> None:
"""Test changing url path from storage config."""
hass_storage[dashboard.DASHBOARDS_STORAGE_KEY] = {
"key": "lovelace_dashboards",
"version": 1,
"data": {
"items": [
{
"icon": "mdi:tools",
"id": "tools",
"mode": "storage",
"require_admin": True,
"show_in_sidebar": True,
"title": "Tools",
"url_path": "tools",
},
{
"icon": "mdi:tools",
"id": "tools2",
"mode": "storage",
"require_admin": True,
"show_in_sidebar": True,
"title": "Tools",
"url_path": "dashboard-tools",
},
]
},
}
assert await async_setup_component(hass, "lovelace", {})
client = await hass_ws_client(hass)
# Fetch data
await client.send_json({"id": 5, "type": "lovelace/dashboards/list"})
response = await client.receive_json()
assert response["success"]
without_hyphen, with_hyphen = response["result"]
assert without_hyphen["icon"] == "mdi:tools"
assert without_hyphen["id"] == "tools"
assert without_hyphen["mode"] == "storage"
assert without_hyphen["require_admin"]
assert without_hyphen["show_in_sidebar"]
assert without_hyphen["title"] == "Tools"
assert without_hyphen["url_path"] == "lovelace-tools"
assert (
with_hyphen
== hass_storage[dashboard.DASHBOARDS_STORAGE_KEY]["data"]["items"][1]
)
async def test_websocket_list_dashboards(
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
) -> None: