diff --git a/tests/components/tolo/test_config_flow.py b/tests/components/tolo/test_config_flow.py index aa88766c395..df36570497b 100644 --- a/tests/components/tolo/test_config_flow.py +++ b/tests/components/tolo/test_config_flow.py @@ -23,6 +23,18 @@ def toloclient_fixture() -> Mock: yield toloclient +@pytest.fixture +def coordinator_toloclient() -> Mock: + """Patch ToloClient in async_setup_entry. + + Throw exception to abort entry setup and prevent socket IO. Only testing config flow. + """ + with patch( + "homeassistant.components.tolo.ToloClient", side_effect=Exception + ) as toloclient: + yield toloclient + + async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: Mock) -> None: """Test a user initiated config flow with provided host which times out.""" toloclient().get_status_info.side_effect = ResponseTimedOutError() @@ -38,7 +50,9 @@ async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: Mock) - assert result["errors"] == {"base": "cannot_connect"} -async def test_user_walkthrough(hass: HomeAssistant, toloclient: Mock) -> None: +async def test_user_walkthrough( + hass: HomeAssistant, toloclient: Mock, coordinator_toloclient: Mock +) -> None: """Test complete user flow with first wrong and then correct host.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} @@ -70,7 +84,9 @@ async def test_user_walkthrough(hass: HomeAssistant, toloclient: Mock) -> None: assert result3["data"][CONF_HOST] == "127.0.0.1" -async def test_dhcp(hass: HomeAssistant, toloclient: Mock) -> None: +async def test_dhcp( + hass: HomeAssistant, toloclient: Mock, coordinator_toloclient: Mock +) -> None: """Test starting a flow from discovery.""" toloclient().get_status_info.side_effect = lambda *args, **kwargs: object()