mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Test platform setup errors are notified (#104384)
Test setup errors are notified
This commit is contained in:
parent
968563253f
commit
3a42bd35e7
@ -719,6 +719,7 @@ async def test_setup_hass_invalid_core_config(
|
|||||||
event_loop: asyncio.AbstractEventLoop,
|
event_loop: asyncio.AbstractEventLoop,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test it works."""
|
"""Test it works."""
|
||||||
|
with patch("homeassistant.config.async_notify_setup_error") as mock_notify:
|
||||||
hass = await bootstrap.async_setup_hass(
|
hass = await bootstrap.async_setup_hass(
|
||||||
runner.RuntimeConfig(
|
runner.RuntimeConfig(
|
||||||
config_dir=get_test_config_dir(),
|
config_dir=get_test_config_dir(),
|
||||||
@ -730,6 +731,7 @@ async def test_setup_hass_invalid_core_config(
|
|||||||
recovery_mode=False,
|
recovery_mode=False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
assert len(mock_notify.mock_calls) == 1
|
||||||
|
|
||||||
assert "recovery_mode" in hass.config.components
|
assert "recovery_mode" in hass.config.components
|
||||||
|
|
||||||
|
@ -373,7 +373,9 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
|||||||
MockPlatform(platform_schema=platform_schema, setup_platform=mock_setup),
|
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(
|
assert await setup.async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
"switch",
|
"switch",
|
||||||
@ -381,11 +383,14 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert mock_setup.call_count == 0
|
assert mock_setup.call_count == 0
|
||||||
|
assert len(mock_notify.mock_calls) == 1
|
||||||
|
|
||||||
hass.data.pop(setup.DATA_SETUP)
|
hass.data.pop(setup.DATA_SETUP)
|
||||||
hass.config.components.remove("switch")
|
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(
|
assert await setup.async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
"switch",
|
"switch",
|
||||||
@ -399,11 +404,14 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert mock_setup.call_count == 0
|
assert mock_setup.call_count == 0
|
||||||
|
assert len(mock_notify.mock_calls) == 1
|
||||||
|
|
||||||
hass.data.pop(setup.DATA_SETUP)
|
hass.data.pop(setup.DATA_SETUP)
|
||||||
hass.config.components.remove("switch")
|
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(
|
assert await setup.async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
"switch",
|
"switch",
|
||||||
@ -411,6 +419,7 @@ async def test_platform_specific_config_validation(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert mock_setup.call_count == 1
|
assert mock_setup.call_count == 1
|
||||||
|
assert len(mock_notify.mock_calls) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_disable_component_if_invalid_return(hass: HomeAssistant) -> None:
|
async def test_disable_component_if_invalid_return(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user