Don't allow partial update of input_number settings (#78356)

This commit is contained in:
Erik Montnemery 2022-09-13 20:54:52 +02:00 committed by GitHub
parent 0e7c81288f
commit 15f104911a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 31 deletions

View file

@ -507,16 +507,14 @@ async def test_ws_delete(hass, hass_ws_client, storage_setup):
async def test_update_min_max(hass, hass_ws_client, storage_setup):
"""Test updating min/max updates the state."""
items = [
{
"id": "from_storage",
"name": "from storage",
"max": 100,
"min": 0,
"step": 1,
"mode": "slider",
}
]
settings = {
"name": "from storage",
"max": 100,
"min": 0,
"step": 1,
"mode": "slider",
}
items = [{"id": "from_storage"} | settings]
assert await storage_setup(items)
input_id = "from_storage"
@ -530,26 +528,34 @@ async def test_update_min_max(hass, hass_ws_client, storage_setup):
client = await hass_ws_client(hass)
updated_settings = settings | {"min": 9}
await client.send_json(
{"id": 6, "type": f"{DOMAIN}/update", f"{DOMAIN}_id": f"{input_id}", "min": 9}
{
"id": 6,
"type": f"{DOMAIN}/update",
f"{DOMAIN}_id": f"{input_id}",
**updated_settings,
}
)
resp = await client.receive_json()
assert resp["success"]
assert resp["result"] == {"id": "from_storage"} | updated_settings
state = hass.states.get(input_entity_id)
assert float(state.state) == 9
updated_settings = settings | {"max": 5}
await client.send_json(
{
"id": 7,
"type": f"{DOMAIN}/update",
f"{DOMAIN}_id": f"{input_id}",
"max": 5,
"min": 0,
**updated_settings,
}
)
resp = await client.receive_json()
assert resp["success"]
assert resp["result"] == {"id": "from_storage"} | updated_settings
state = hass.states.get(input_entity_id)
assert float(state.state) == 5