From 0c7805bc6652c052f77cf67beb15ad8ddbbef281 Mon Sep 17 00:00:00 2001 From: farmio Date: Mon, 2 Jun 2025 21:36:33 +0200 Subject: [PATCH] More tests --- tests/components/knx/test_config_store.py | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/components/knx/test_config_store.py b/tests/components/knx/test_config_store.py index aa88cba20b4..b67724642db 100644 --- a/tests/components/knx/test_config_store.py +++ b/tests/components/knx/test_config_store.py @@ -380,6 +380,7 @@ async def test_validate_entity( await knx.setup_integration() client = await hass_ws_client(hass) + # valid data await client.send_json_auto_id( { "type": "knx/validate_entity", @@ -412,6 +413,37 @@ async def test_validate_entity( assert res["result"]["errors"][0]["error_message"] == "required key not provided" assert res["result"]["error_base"].startswith("required key not provided") + # invalid group_select data + await client.send_json_auto_id( + { + "type": "knx/validate_entity", + "platform": Platform.LIGHT, + "data": { + "entity": {"name": "test_name"}, + "knx": { + "color": { + "ga_red_brightness": {"write": "1/2/3"}, + "ga_green_brightness": {"write": "1/2/4"}, + # ga_blue_brightness is missing - which is required + } + }, + }, + } + ) + res = await client.receive_json() + assert res["success"], res + assert res["result"]["success"] is False + # This shall test that a required key of the second GroupSelect schema is missing + # and not not yield the "extra keys not allowed" error of the first GroupSelect Schema + assert res["result"]["errors"][0]["path"] == [ + "data", + "knx", + "color", + "ga_blue_brightness", + ] + assert res["result"]["errors"][0]["error_message"] == "required key not provided" + assert res["result"]["error_base"].startswith("required key not provided") + async def test_migration_1_to_2( hass: HomeAssistant,