diff --git a/tests/components/bond/test_config_flow.py b/tests/components/bond/test_config_flow.py index e3f441ab56f..4a6efa8f89b 100644 --- a/tests/components/bond/test_config_flow.py +++ b/tests/components/bond/test_config_flow.py @@ -194,20 +194,21 @@ async def test_user_form_one_entry_per_device_allowed(hass: core.HomeAssistant): async def test_zeroconf_form(hass: core.HomeAssistant): """Test we get the discovery form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.ZeroconfServiceInfo( - host="test-host", - hostname="mock_hostname", - name="test-bond-id.some-other-tail-info", - port=None, - properties={}, - type="mock_type", - ), - ) - assert result["type"] == "form" - assert result["errors"] == {} + with patch_bond_version(), patch_bond_token(): + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={"source": config_entries.SOURCE_ZEROCONF}, + data=zeroconf.ZeroconfServiceInfo( + host="test-host", + hostname="mock_hostname", + name="test-bond-id.some-other-tail-info", + port=None, + properties={}, + type="mock_type", + ), + ) + assert result["type"] == "form" + assert result["errors"] == {} with patch_bond_version( return_value={"bondid": "test-bond-id"} @@ -326,13 +327,12 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant): type="mock_type", ), ) + await hass.async_block_till_done() assert result["type"] == "abort" assert result["reason"] == "already_configured" assert entry.data["host"] == "updated-host" - - await hass.async_block_till_done() - assert len(mock_setup_entry.mock_calls) == 0 + assert len(mock_setup_entry.mock_calls) == 1 async def test_zeroconf_already_configured_refresh_token(hass: core.HomeAssistant): @@ -442,9 +442,10 @@ async def _help_test_form_unexpected_error( error: Exception, ): """Test we handle unexpected error gracefully.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": source}, data=initial_input - ) + with patch_bond_token(): + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": source}, data=initial_input + ) with patch_bond_version( return_value={"bond_id": "test-bond-id"}