diff --git a/tests/components/airthings_ble/__init__.py b/tests/components/airthings_ble/__init__.py index 3f7e877e5c43..eeac0a1af99f 100644 --- a/tests/components/airthings_ble/__init__.py +++ b/tests/components/airthings_ble/__init__.py @@ -25,8 +25,8 @@ from homeassistant.helpers.device_registry import ( ) -def patch_async_setup_entry(return_value=True): - """Patch async setup entry to return True.""" +def patch_async_setup_entry(return_value=None): + """Patch async setup entry to return None.""" return patch( "homeassistant.components.airthings_ble.async_setup_entry", return_value=return_value, diff --git a/tests/components/avea/test_init.py b/tests/components/avea/test_init.py index 5f2d108eae31..1bc1e7070a5a 100644 --- a/tests/components/avea/test_init.py +++ b/tests/components/avea/test_init.py @@ -41,7 +41,7 @@ async def _setup_yaml_import(hass: HomeAssistant, bulbs: list[MagicMock]) -> Non ), patch( "homeassistant.components.avea.async_setup_entry", - new=AsyncMock(return_value=True), + new=AsyncMock(return_value=None), ), ): assert await async_setup_component( diff --git a/tests/components/azure_data_explorer/conftest.py b/tests/components/azure_data_explorer/conftest.py index 24cc6ecc3053..970a45977dee 100644 --- a/tests/components/azure_data_explorer/conftest.py +++ b/tests/components/azure_data_explorer/conftest.py @@ -96,7 +96,7 @@ async def mock_entry_with_one_event( def mock_setup_entry() -> Generator[AsyncMock]: """Mock the setup entry call, used for config flow tests.""" with patch( - f"{AZURE_DATA_EXPLORER_PATH}.async_setup_entry", return_value=True + f"{AZURE_DATA_EXPLORER_PATH}.async_setup_entry", return_value=None ) as setup_entry: yield setup_entry diff --git a/tests/components/azure_event_hub/conftest.py b/tests/components/azure_event_hub/conftest.py index d8c622e8cd3f..d5f51a047b85 100644 --- a/tests/components/azure_event_hub/conftest.py +++ b/tests/components/azure_event_hub/conftest.py @@ -136,6 +136,6 @@ def mock_from_connection_string_fixture() -> Generator[MagicMock]: def mock_setup_entry() -> Generator[AsyncMock]: """Mock the setup entry call, used for config flow tests.""" with patch( - f"{AZURE_EVENT_HUB_PATH}.async_setup_entry", return_value=True + f"{AZURE_EVENT_HUB_PATH}.async_setup_entry", return_value=None ) as setup_entry: yield setup_entry diff --git a/tests/components/caldav/test_config_flow.py b/tests/components/caldav/test_config_flow.py index 1ce51b381ebf..9d0e16334e3f 100644 --- a/tests/components/caldav/test_config_flow.py +++ b/tests/components/caldav/test_config_flow.py @@ -22,7 +22,7 @@ from .conftest import TEST_PASSWORD, TEST_URL, TEST_USERNAME def mock_setup_entry() -> Generator[AsyncMock]: """Override async_setup_entry.""" with patch( - f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=True + f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=None ) as mock_setup_entry: yield mock_setup_entry diff --git a/tests/components/canary/__init__.py b/tests/components/canary/__init__.py index fab6a722649f..980956dbe973 100644 --- a/tests/components/canary/__init__.py +++ b/tests/components/canary/__init__.py @@ -36,7 +36,7 @@ YAML_CONFIG = { } -def _patch_async_setup_entry(return_value=True): +def _patch_async_setup_entry(return_value=None): return patch( "homeassistant.components.canary.async_setup_entry", return_value=return_value, diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index 64ddec9d9797..d03442c604b6 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -28,7 +28,7 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS from homeassistant.core import HomeAssistant, callback from homeassistant.data_entry_flow import FlowResultType -from homeassistant.exceptions import ConfigEntryNotReady +from homeassistant.exceptions import ConfigEntryError, ConfigEntryNotReady from homeassistant.helpers import config_entry_flow, config_validation as cv from homeassistant.helpers.discovery_flow import DiscoveryKey from homeassistant.helpers.service_info.hassio import HassioServiceInfo @@ -2307,7 +2307,9 @@ async def test_disable_entry( core_ce.ConfigEntryState.SETUP_RETRY, id="setup_retry", ), - pytest.param(None, core_ce.ConfigEntryState.SETUP_ERROR, id="setup_error"), + pytest.param( + ConfigEntryError, core_ce.ConfigEntryState.SETUP_ERROR, id="setup_error" + ), ], ) @pytest.mark.parametrize( @@ -2320,7 +2322,7 @@ async def test_disable_entry( async def test_enable_entry_setup_fails( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - side_effect: type[Exception] | None, + side_effect: type[Exception], expected_state: core_ce.ConfigEntryState, loaded_components: set[str], ) -> None: @@ -2328,7 +2330,7 @@ async def test_enable_entry_setup_fails( assert await async_setup_component(hass, DOMAIN, {}) ws_client = await hass_ws_client(hass) - mock_setup_entry = AsyncMock(side_effect=side_effect, return_value=False) + mock_setup_entry = AsyncMock(side_effect=side_effect) mock_integration(hass, MockModule("comp", async_setup_entry=mock_setup_entry)) mock_platform(hass, "comp.config_flow", None) entry = MockConfigEntry(domain="comp", disabled_by=core_ce.ConfigEntryDisabler.USER) @@ -2361,7 +2363,7 @@ async def test_enable_entry_component_setup_fails( assert await async_setup_component(hass, DOMAIN, {}) ws_client = await hass_ws_client(hass) - mock_setup_entry = AsyncMock(return_value=True) + mock_setup_entry = AsyncMock(return_value=None) mock_integration( hass, MockModule( diff --git a/tests/components/elkm1/test_config_flow.py b/tests/components/elkm1/test_config_flow.py index fc739fc33e29..3aef266ae18b 100644 --- a/tests/components/elkm1/test_config_flow.py +++ b/tests/components/elkm1/test_config_flow.py @@ -2390,7 +2390,7 @@ async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None: _patch_discovery(), _patch_elk(mocked_elk), patch(f"{MODULE}.async_setup", return_value=True), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], diff --git a/tests/components/flux_led/test_config_flow.py b/tests/components/flux_led/test_config_flow.py index 931c5dd4aa6b..8fff29d9bde0 100644 --- a/tests/components/flux_led/test_config_flow.py +++ b/tests/components/flux_led/test_config_flow.py @@ -81,7 +81,7 @@ async def test_discovery(hass: HomeAssistant) -> None: _patch_discovery(), _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_setup, - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result3 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -157,7 +157,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None: _patch_discovery(), _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_setup, - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result3 = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -244,7 +244,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No with ( _patch_discovery(), _patch_wifibulb(), - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result3 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_DEVICE: MAC_ADDRESS} @@ -322,7 +322,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None: _patch_discovery(), _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result4 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -389,7 +389,7 @@ async def test_user_flow_can_replace_ignored(hass: HomeAssistant) -> None: _patch_discovery(), _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result4 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -423,7 +423,7 @@ async def test_manual_no_discovery_data(hass: HomeAssistant) -> None: _patch_discovery(no_device=True), _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -513,7 +513,7 @@ async def test_discovered_by_discovery(hass: HomeAssistant) -> None: _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -553,7 +553,7 @@ async def test_discovered_by_dhcp_udp_responds(hass: HomeAssistant) -> None: _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -593,7 +593,7 @@ async def test_discovered_by_dhcp_no_udp_response(hass: HomeAssistant) -> None: _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -629,7 +629,7 @@ async def test_discovered_by_dhcp_partial_udp_response_fallback_tcp( _patch_wifibulb(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index 4db7ffa6e441..da8c0b1ab214 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -1367,7 +1367,7 @@ async def test_setup_hardware_integration( patch.dict(os.environ, MOCK_ENVIRON), patch( f"homeassistant.components.{integration}.async_setup_entry", - return_value=True, + return_value=None, ) as mock_setup_entry, patch( "homeassistant.components.homeassistant_yellow.config_flow.probe_silabs_firmware_info", diff --git a/tests/components/keymitt_ble/__init__.py b/tests/components/keymitt_ble/__init__.py index e0871e034009..80462258276b 100644 --- a/tests/components/keymitt_ble/__init__.py +++ b/tests/components/keymitt_ble/__init__.py @@ -25,8 +25,8 @@ USER_INPUT_INVALID = { } -def patch_async_setup_entry(return_value=True): - """Patch async setup entry to return True.""" +def patch_async_setup_entry(return_value=None): + """Patch async setup entry to return None.""" return patch( "homeassistant.components.keymitt_ble.async_setup_entry", return_value=return_value, diff --git a/tests/components/llama_cpp/test_config_flow.py b/tests/components/llama_cpp/test_config_flow.py index 3b21de8e2099..97a9d08cd09d 100644 --- a/tests/components/llama_cpp/test_config_flow.py +++ b/tests/components/llama_cpp/test_config_flow.py @@ -37,7 +37,7 @@ RECOMMENDED_OPTIONS = { def mock_setup(hass: HomeAssistant) -> Generator[AsyncMock]: """Mock the setup of the integration.""" with patch( - f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=True + f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=None ) as mock_setup_entry: yield mock_setup_entry diff --git a/tests/components/lookin/test_config_flow.py b/tests/components/lookin/test_config_flow.py index 487bee0b91b8..e15f7aa69570 100644 --- a/tests/components/lookin/test_config_flow.py +++ b/tests/components/lookin/test_config_flow.py @@ -35,7 +35,7 @@ async def test_manual_setup(hass: HomeAssistant) -> None: with ( _patch_get_info(), - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -92,7 +92,7 @@ async def test_manual_setup_device_offline(hass: HomeAssistant) -> None: with ( _patch_get_info(), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -122,7 +122,7 @@ async def test_manual_setup_unknown_exception(hass: HomeAssistant) -> None: with ( _patch_get_info(), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -149,7 +149,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None: with ( _patch_get_info(), patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -168,7 +168,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None: with ( _patch_get_info(), patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result = await hass.config_entries.flow.async_init( diff --git a/tests/components/myuplink/test_config_flow.py b/tests/components/myuplink/test_config_flow.py index 6c2e165a582f..778a633673c2 100644 --- a/tests/components/myuplink/test_config_flow.py +++ b/tests/components/myuplink/test_config_flow.py @@ -66,7 +66,7 @@ async def test_full_flow( ) with patch( - f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=True + f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=None ) as mock_setup: result = await hass.config_entries.flow.async_configure(result["flow_id"]) await hass.async_block_till_done() @@ -171,7 +171,7 @@ async def test_flow_reauth_abort( ) with patch( - f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=True + f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=None ): result = await hass.config_entries.flow.async_configure(result["flow_id"]) await hass.async_block_till_done() @@ -264,7 +264,7 @@ async def test_flow_reconfigure_abort( ) with patch( - f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=True + f"homeassistant.components.{DOMAIN}.async_setup_entry", return_value=None ): result = await hass.config_entries.flow.async_configure(result["flow_id"]) await hass.async_block_till_done() diff --git a/tests/components/nzbget/__init__.py b/tests/components/nzbget/__init__.py index 1747644931c2..8b276aeb262d 100644 --- a/tests/components/nzbget/__init__.py +++ b/tests/components/nzbget/__init__.py @@ -71,7 +71,7 @@ async def init_integration(hass: HomeAssistant) -> MockConfigEntry: return entry -def _patch_async_setup_entry(return_value=True): +def _patch_async_setup_entry(return_value=None): return patch( "homeassistant.components.nzbget.async_setup_entry", return_value=return_value, diff --git a/tests/components/radarr/__init__.py b/tests/components/radarr/__init__.py index 9d5d6c0a9fd0..8c44f8ed8bab 100644 --- a/tests/components/radarr/__init__.py +++ b/tests/components/radarr/__init__.py @@ -198,7 +198,7 @@ async def setup_integration( return entry -def patch_async_setup_entry(return_value=True): +def patch_async_setup_entry(return_value=None): """Patch the async entry setup of radarr.""" return patch( "homeassistant.components.radarr.async_setup_entry", diff --git a/tests/components/vicare/conftest.py b/tests/components/vicare/conftest.py index 7dbc658a95a5..937e386d2e05 100644 --- a/tests/components/vicare/conftest.py +++ b/tests/components/vicare/conftest.py @@ -198,5 +198,5 @@ async def mock_vicare_room_sensors( @pytest.fixture def mock_setup_entry() -> Generator[AsyncMock]: """Mock setting up a config entry.""" - with patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry: + with patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry: yield mock_setup_entry diff --git a/tests/components/yeelight/test_config_flow.py b/tests/components/yeelight/test_config_flow.py index 922505f4c89d..33d548df0a47 100644 --- a/tests/components/yeelight/test_config_flow.py +++ b/tests/components/yeelight/test_config_flow.py @@ -101,7 +101,7 @@ async def test_discovery(hass: HomeAssistant) -> None: _patch_discovery(), _patch_discovery_interval(), patch(f"{MODULE}.async_setup", return_value=True) as mock_setup, - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result3 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_DEVICE: ID} @@ -260,7 +260,7 @@ async def test_import(hass: HomeAssistant) -> None: _patch_discovery(), patch(f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb), patch(f"{MODULE}.async_setup", return_value=True) as mock_setup, - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config @@ -336,7 +336,7 @@ async def test_manual(hass: HomeAssistant) -> None: _patch_discovery_timeout(), patch(f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb), patch(f"{MODULE}.async_setup", return_value=True), - patch(f"{MODULE}.async_setup_entry", return_value=True), + patch(f"{MODULE}.async_setup_entry", return_value=None), ): result4 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: IP_ADDRESS} @@ -474,7 +474,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None: ), patch( f"{MODULE}.async_setup_entry", - return_value=True, + return_value=None, ), ): result = await hass.config_entries.flow.async_configure( @@ -622,7 +622,7 @@ async def test_discovered_by_dhcp_or_homekit(hass: HomeAssistant, source, data) _patch_discovery_interval(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -715,7 +715,7 @@ async def test_discovered_ssdp(hass: HomeAssistant) -> None: _patch_discovery_interval(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -770,7 +770,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None: _patch_discovery_interval(), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, ): result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -858,7 +858,7 @@ async def test_discovery_updates_ip_no_reload_setup_in_progress( mocked_bulb = _mocked_bulb() with ( - patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry, + patch(f"{MODULE}.async_setup_entry", return_value=None) as mock_setup_entry, _patch_discovery(), _patch_discovery_interval(), patch(f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb), @@ -931,7 +931,7 @@ async def test_discovered_during_onboarding(hass: HomeAssistant, source, data) - patch(f"{MODULE_CONFIG_FLOW}.AsyncBulb", return_value=mocked_bulb), patch(f"{MODULE}.async_setup", return_value=True) as mock_async_setup, patch( - f"{MODULE}.async_setup_entry", return_value=True + f"{MODULE}.async_setup_entry", return_value=None ) as mock_async_setup_entry, patch( "homeassistant.components.onboarding.async_is_onboarded", return_value=False