Fix slow config_flow test in bond (#60355)

This commit is contained in:
Michael 2021-11-25 19:32:26 +01:00 committed by GitHub
parent 03d1efab46
commit fb909eca8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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): async def test_zeroconf_form(hass: core.HomeAssistant):
"""Test we get the discovery form.""" """Test we get the discovery form."""
result = await hass.config_entries.flow.async_init( with patch_bond_version(), patch_bond_token():
DOMAIN, result = await hass.config_entries.flow.async_init(
context={"source": config_entries.SOURCE_ZEROCONF}, DOMAIN,
data=zeroconf.ZeroconfServiceInfo( context={"source": config_entries.SOURCE_ZEROCONF},
host="test-host", data=zeroconf.ZeroconfServiceInfo(
hostname="mock_hostname", host="test-host",
name="test-bond-id.some-other-tail-info", hostname="mock_hostname",
port=None, name="test-bond-id.some-other-tail-info",
properties={}, port=None,
type="mock_type", properties={},
), type="mock_type",
) ),
assert result["type"] == "form" )
assert result["errors"] == {} assert result["type"] == "form"
assert result["errors"] == {}
with patch_bond_version( with patch_bond_version(
return_value={"bondid": "test-bond-id"} return_value={"bondid": "test-bond-id"}
@ -326,13 +327,12 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant):
type="mock_type", type="mock_type",
), ),
) )
await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] == "abort"
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "updated-host" assert entry.data["host"] == "updated-host"
assert len(mock_setup_entry.mock_calls) == 1
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 0
async def test_zeroconf_already_configured_refresh_token(hass: core.HomeAssistant): async def test_zeroconf_already_configured_refresh_token(hass: core.HomeAssistant):
@ -442,9 +442,10 @@ async def _help_test_form_unexpected_error(
error: Exception, error: Exception,
): ):
"""Test we handle unexpected error gracefully.""" """Test we handle unexpected error gracefully."""
result = await hass.config_entries.flow.async_init( with patch_bond_token():
DOMAIN, context={"source": source}, data=initial_input result = await hass.config_entries.flow.async_init(
) DOMAIN, context={"source": source}, data=initial_input
)
with patch_bond_version( with patch_bond_version(
return_value={"bond_id": "test-bond-id"} return_value={"bond_id": "test-bond-id"}