From ff7b94eb8a6ebe4629326d60f932f6a80b704bd4 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Apr 2021 16:22:56 +0000 Subject: [PATCH 1/2] Test that we do not initialize bad configuration --- tests/components/automation/test_init.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 71727258fcc45..312d56f60578b 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -1357,6 +1357,29 @@ async def test_blueprint_automation(hass, calls): ] +async def test_blueprint_automation_bad_config(hass, calls, caplog): + """Test blueprint automation with bad inputs.""" + assert await async_setup_component( + hass, + "automation", + { + "automation": { + "use_blueprint": { + "path": "test_event_service.yaml", + "input": { + "trigger_event": "blueprint_event", + "service_to_call": {"dict": "not allowed"}, + }, + } + } + }, + ) + hass.bus.async_fire("blueprint_event") + await hass.async_block_till_done() + assert len(calls) == 0 + assert "generated invalid automation" in caplog.text + + async def test_trigger_service(hass, calls): """Test the automation trigger service.""" assert await async_setup_component( From c67138e3da20d8f7a40279175d49260f0e385048 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Apr 2021 16:26:55 +0000 Subject: [PATCH 2/2] Simplify test as we are not calling a service --- tests/components/automation/test_init.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 312d56f60578b..5997be22644ce 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -1357,7 +1357,7 @@ async def test_blueprint_automation(hass, calls): ] -async def test_blueprint_automation_bad_config(hass, calls, caplog): +async def test_blueprint_automation_bad_config(hass, caplog): """Test blueprint automation with bad inputs.""" assert await async_setup_component( hass, @@ -1374,9 +1374,6 @@ async def test_blueprint_automation_bad_config(hass, calls, caplog): } }, ) - hass.bus.async_fire("blueprint_event") - await hass.async_block_till_done() - assert len(calls) == 0 assert "generated invalid automation" in caplog.text