mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 04:05:06 +02:00
Test platform setup errors are notified (#104384)
Test setup errors are notified
This commit is contained in:
@@ -373,7 +373,9 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
||||
MockPlatform(platform_schema=platform_schema, setup_platform=mock_setup),
|
||||
)
|
||||
|
||||
with assert_setup_component(0, "switch"):
|
||||
with assert_setup_component(0, "switch"), patch(
|
||||
"homeassistant.config.async_notify_setup_error"
|
||||
) as mock_notify:
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"switch",
|
||||
@@ -381,11 +383,14 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_setup.call_count == 0
|
||||
assert len(mock_notify.mock_calls) == 1
|
||||
|
||||
hass.data.pop(setup.DATA_SETUP)
|
||||
hass.config.components.remove("switch")
|
||||
|
||||
with assert_setup_component(0):
|
||||
with assert_setup_component(0), patch(
|
||||
"homeassistant.config.async_notify_setup_error"
|
||||
) as mock_notify:
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"switch",
|
||||
@@ -399,11 +404,14 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_setup.call_count == 0
|
||||
assert len(mock_notify.mock_calls) == 1
|
||||
|
||||
hass.data.pop(setup.DATA_SETUP)
|
||||
hass.config.components.remove("switch")
|
||||
|
||||
with assert_setup_component(1, "switch"):
|
||||
with assert_setup_component(1, "switch"), patch(
|
||||
"homeassistant.config.async_notify_setup_error"
|
||||
) as mock_notify:
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"switch",
|
||||
@@ -411,6 +419,7 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_setup.call_count == 1
|
||||
assert len(mock_notify.mock_calls) == 0
|
||||
|
||||
|
||||
async def test_disable_component_if_invalid_return(hass: HomeAssistant) -> None:
|
||||
|
Reference in New Issue
Block a user