mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Remove old migration from lovelace (#113388)
This commit is contained in:
parent
7ae852e5ed
commit
9eea786411
@ -232,23 +232,6 @@ class DashboardsCollection(collection.DictStorageCollection):
|
|||||||
storage.Store(hass, DASHBOARDS_STORAGE_VERSION, DASHBOARDS_STORAGE_KEY),
|
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:
|
async def _process_create_data(self, data: dict) -> dict:
|
||||||
"""Validate the config is valid."""
|
"""Validate the config is valid."""
|
||||||
if "-" not in data[CONF_URL_PATH]:
|
if "-" not in data[CONF_URL_PATH]:
|
||||||
|
@ -441,61 +441,6 @@ async def test_storage_dashboards(
|
|||||||
assert dashboard.CONFIG_STORAGE_KEY.format(dashboard_id) not in hass_storage
|
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(
|
async def test_websocket_list_dashboards(
|
||||||
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
hass: HomeAssistant, hass_ws_client: WebSocketGenerator
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user