ConfigFlow default discovery without unique ID (#36754)
This commit is contained in:
1 parent
dfac9c5e03
commit
3cc94f7d6a
32 files changed
+408
-170
No files matched your search
@@ -82,7 +82,7 @@ async def test_abort_if_existing_entry(hass):
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
|
||||
result = await flow.async_step_hassio()
|
||||
result = await flow.async_step_hassio({})
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
|
||||
|
||||
@@ -264,10 +264,10 @@ async def test_zeroconf_with_uuid_device_exists_abort(
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_zeroconf_empty_unique_id_required_abort(
|
||||
async def test_zeroconf_empty_unique_id(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test we abort zeroconf flow if printer lacks (empty) unique identification."""
|
||||
"""Test zeroconf flow if printer lacks (empty) unique identification."""
|
||||
mock_connection(aioclient_mock, no_unique_id=True)
|
||||
|
||||
discovery_info = {
|
||||
@@ -278,14 +278,13 @@ async def test_zeroconf_empty_unique_id_required_abort(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "unique_id_required"
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
|
||||
|
||||
async def test_zeroconf_unique_id_required_abort(
|
||||
async def test_zeroconf_no_unique_id(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
) -> None:
|
||||
"""Test we abort zeroconf flow if printer lacks unique identification."""
|
||||
"""Test zeroconf flow if printer lacks unique identification."""
|
||||
mock_connection(aioclient_mock, no_unique_id=True)
|
||||
|
||||
discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy()
|
||||
@@ -293,8 +292,7 @@ async def test_zeroconf_unique_id_required_abort(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "unique_id_required"
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
|
||||
|
||||
async def test_full_user_flow_implementation(
|
||||
|
||||
@@ -13,6 +13,7 @@ from homeassistant.components.tellduslive import (
|
||||
SCAN_INTERVAL,
|
||||
config_flow,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_DISCOVERY
|
||||
from homeassistant.const import CONF_HOST
|
||||
|
||||
from tests.common import MockConfigEntry, mock_coro
|
||||
@@ -73,6 +74,7 @@ async def test_abort_if_already_setup(hass):
|
||||
async def test_full_flow_implementation(hass, mock_tellduslive):
|
||||
"""Test registering an implementation and finishing flow works."""
|
||||
flow = init_config_flow(hass)
|
||||
flow.context = {"source": SOURCE_DISCOVERY}
|
||||
result = await flow.async_step_discovery(["localhost", "tellstick"])
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
@@ -166,6 +168,7 @@ async def test_step_import_load_json(hass, mock_tellduslive):
|
||||
async def test_step_disco_no_local_api(hass, mock_tellduslive):
|
||||
"""Test that we trigger when configuring from discovery, not supporting local api."""
|
||||
flow = init_config_flow(hass)
|
||||
flow.context = {"source": SOURCE_DISCOVERY}
|
||||
|
||||
result = await flow.async_step_discovery(["localhost", "tellstick"])
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -242,7 +245,7 @@ async def test_discovery_already_configured(hass, mock_tellduslive):
|
||||
"""Test abort if already configured fires from discovery."""
|
||||
MockConfigEntry(domain="tellduslive", data={"host": "some-host"}).add_to_hass(hass)
|
||||
flow = init_config_flow(hass)
|
||||
flow.context = {"source": SOURCE_DISCOVERY}
|
||||
|
||||
result = await flow.async_step_discovery(["some-host", ""])
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
with pytest.raises(data_entry_flow.AbortFlow):
|
||||
result = await flow.async_step_discovery(["some-host", ""])
|
||||
Reference in new issue
Block a user