Lovelace: storage key based on id instead of url_path (#32873)

* Fix storage key based on url_path

* Fix test
This commit is contained in:
Bram Kragten 2020-03-16 20:08:00 +01:00 committed by GitHub
parent 999c5443c1
commit 2f1824774f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -88,7 +88,7 @@ class LovelaceStorage(LovelaceConfig):
storage_key = CONFIG_STORAGE_KEY_DEFAULT storage_key = CONFIG_STORAGE_KEY_DEFAULT
else: else:
url_path = config[CONF_URL_PATH] url_path = config[CONF_URL_PATH]
storage_key = CONFIG_STORAGE_KEY.format(url_path) storage_key = CONFIG_STORAGE_KEY.format(config["id"])
super().__init__(hass, url_path, config) super().__init__(hass, url_path, config)

View File

@ -373,7 +373,6 @@ async def test_storage_dashboards(hass, hass_ws_client, hass_storage):
assert response["result"]["icon"] == "mdi:map" assert response["result"]["icon"] == "mdi:map"
dashboard_id = response["result"]["id"] dashboard_id = response["result"]["id"]
dashboard_path = response["result"]["url_path"]
assert "created-url-path" in hass.data[frontend.DATA_PANELS] assert "created-url-path" in hass.data[frontend.DATA_PANELS]
@ -408,9 +407,9 @@ async def test_storage_dashboards(hass, hass_ws_client, hass_storage):
) )
response = await client.receive_json() response = await client.receive_json()
assert response["success"] assert response["success"]
assert hass_storage[dashboard.CONFIG_STORAGE_KEY.format(dashboard_path)][ assert hass_storage[dashboard.CONFIG_STORAGE_KEY.format(dashboard_id)]["data"] == {
"data" "config": {"yo": "hello"}
] == {"config": {"yo": "hello"}} }
assert len(events) == 1 assert len(events) == 1
assert events[0].data["url_path"] == "created-url-path" assert events[0].data["url_path"] == "created-url-path"