diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index f5e01e0c97b..c3e25219369 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -719,17 +719,19 @@ async def test_setup_hass_invalid_core_config( event_loop: asyncio.AbstractEventLoop, ) -> None: """Test it works.""" - hass = await bootstrap.async_setup_hass( - runner.RuntimeConfig( - config_dir=get_test_config_dir(), - verbose=False, - log_rotate_days=10, - log_file="", - log_no_color=False, - skip_pip=True, - recovery_mode=False, - ), - ) + with patch("homeassistant.config.async_notify_setup_error") as mock_notify: + hass = await bootstrap.async_setup_hass( + runner.RuntimeConfig( + config_dir=get_test_config_dir(), + verbose=False, + log_rotate_days=10, + log_file="", + log_no_color=False, + skip_pip=True, + recovery_mode=False, + ), + ) + assert len(mock_notify.mock_calls) == 1 assert "recovery_mode" in hass.config.components diff --git a/tests/test_setup.py b/tests/test_setup.py index 66a62511fcb..0f480198c11 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -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: