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):
"""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"}