mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Add command to delete lovelace config (#30558)
* Add command to delete lovelace config * Test + decorator for WS
This commit is contained in:
committed by
Paulus Schoutsen
parent
1ce662d699
commit
16199b7a52
@@ -55,6 +55,32 @@ async def test_lovelace_from_storage_save_before_load(
|
||||
assert hass_storage[lovelace.STORAGE_KEY]["data"] == {"config": {"yo": "hello"}}
|
||||
|
||||
|
||||
async def test_lovelace_from_storage_delete(hass, hass_ws_client, hass_storage):
|
||||
"""Test we delete lovelace config from storage."""
|
||||
assert await async_setup_component(hass, "lovelace", {})
|
||||
client = await hass_ws_client(hass)
|
||||
|
||||
# Store new config
|
||||
await client.send_json(
|
||||
{"id": 6, "type": "lovelace/config/save", "config": {"yo": "hello"}}
|
||||
)
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert hass_storage[lovelace.STORAGE_KEY]["data"] == {"config": {"yo": "hello"}}
|
||||
|
||||
# Delete config
|
||||
await client.send_json({"id": 7, "type": "lovelace/config/delete"})
|
||||
response = await client.receive_json()
|
||||
assert response["success"]
|
||||
assert hass_storage[lovelace.STORAGE_KEY]["data"] == {"config": None}
|
||||
|
||||
# Fetch data
|
||||
await client.send_json({"id": 8, "type": "lovelace/config"})
|
||||
response = await client.receive_json()
|
||||
assert not response["success"]
|
||||
assert response["error"]["code"] == "config_not_found"
|
||||
|
||||
|
||||
async def test_lovelace_from_yaml(hass, hass_ws_client):
|
||||
"""Test we load lovelace config from yaml."""
|
||||
assert await async_setup_component(hass, "lovelace", {"lovelace": {"mode": "YAML"}})
|
||||
|
||||
Reference in New Issue
Block a user