Use is in enum comparison in config flow tests K-O (#114672)
This commit is contained in:
parent
3875533f95
commit
5d500cb74b
107 changed files with 1177 additions and 1147 deletions
|
@ -21,7 +21,7 @@ async def test_user_config_flow_success(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -29,7 +29,7 @@ async def test_user_config_flow_success(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert "data" in result
|
assert "data" in result
|
||||||
assert result["data"][CONF_HOST] == MOCK_HOST
|
assert result["data"][CONF_HOST] == MOCK_HOST
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ async def test_user_config_flow_bad_connect_errors(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ async def test_user_config_flow_unsupported_device_errors(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "unsupported"}
|
assert result["errors"] == {"base": "unsupported"}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ async def test_user_config_flow_device_exists_abort(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: MOCK_HOST}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ async def test_ssdp_config_flow_success(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "discovery_confirm"
|
assert result["step_id"] == "discovery_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -91,7 +91,7 @@ async def test_ssdp_config_flow_success(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert "data" in result
|
assert "data" in result
|
||||||
assert result["data"][CONF_HOST] == MOCK_HOST
|
assert result["data"][CONF_HOST] == MOCK_HOST
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ async def test_ssdp_config_flow_bad_connect_aborts(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,5 +122,5 @@ async def test_ssdp_config_flow_unsupported_device_aborts(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "unsupported"
|
assert result["reason"] == "unsupported"
|
||||||
|
|
|
@ -7,11 +7,12 @@ from ndms2_client import ConnectionException
|
||||||
from ndms2_client.client import InterfaceInfo, RouterInfo
|
from ndms2_client.client import InterfaceInfo, RouterInfo
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import keenetic_ndms2 as keenetic, ssdp
|
from homeassistant.components import keenetic_ndms2 as keenetic, ssdp
|
||||||
from homeassistant.components.keenetic_ndms2 import const
|
from homeassistant.components.keenetic_ndms2 import const
|
||||||
from homeassistant.const import CONF_HOST, CONF_SOURCE
|
from homeassistant.const import CONF_HOST, CONF_SOURCE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import MOCK_DATA, MOCK_NAME, MOCK_OPTIONS, MOCK_SSDP_DISCOVERY_INFO
|
from . import MOCK_DATA, MOCK_NAME, MOCK_OPTIONS, MOCK_SSDP_DISCOVERY_INFO
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ async def test_flow_works(hass: HomeAssistant, connect) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
keenetic.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
keenetic.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -63,7 +64,7 @@ async def test_flow_works(hass: HomeAssistant, connect) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == MOCK_NAME
|
assert result2["title"] == MOCK_NAME
|
||||||
assert result2["data"] == MOCK_DATA
|
assert result2["data"] == MOCK_DATA
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -98,7 +99,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -106,7 +107,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
user_input=MOCK_OPTIONS,
|
user_input=MOCK_OPTIONS,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"] == MOCK_OPTIONS
|
assert result2["data"] == MOCK_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ async def test_host_already_configured(hass: HomeAssistant, connect) -> None:
|
||||||
result["flow_id"], user_input=MOCK_DATA
|
result["flow_id"], user_input=MOCK_DATA
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ async def test_connection_error(hass: HomeAssistant, connect_error) -> None:
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=MOCK_DATA
|
result["flow_id"], user_input=MOCK_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ async def test_ssdp_works(hass: HomeAssistant, connect) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -168,7 +169,7 @@ async def test_ssdp_works(hass: HomeAssistant, connect) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == MOCK_NAME
|
assert result2["title"] == MOCK_NAME
|
||||||
assert result2["data"] == MOCK_DATA
|
assert result2["data"] == MOCK_DATA
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -189,7 +190,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ async def test_ssdp_ignored(hass: HomeAssistant) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ async def test_ssdp_update_host(hass: HomeAssistant) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert entry.data[CONF_HOST] == new_ip
|
assert entry.data[CONF_HOST] == new_ip
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ async def test_ssdp_reject_no_udn(hass: HomeAssistant) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_udn"
|
assert result["reason"] == "no_udn"
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,5 +271,5 @@ async def test_ssdp_reject_non_keenetic(hass: HomeAssistant) -> None:
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_keenetic_ndms2"
|
assert result["reason"] == "not_keenetic_ndms2"
|
||||||
|
|
|
@ -23,13 +23,13 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=KEGTRON_KT100_SERVICE_INFO,
|
data=KEGTRON_KT100_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Kegtron KT-100 9B75"
|
assert result2["title"] == "Kegtron KT-100 9B75"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
||||||
|
@ -42,7 +42,7 @@ async def test_async_step_bluetooth_not_kegtron(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=NOT_KEGTRON_SERVICE_INFO,
|
data=NOT_KEGTRON_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,14 +66,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Kegtron KT-200 9B75"
|
assert result2["title"] == "Kegtron KT-200 9B75"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
||||||
|
@ -89,7 +89,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
@ -103,7 +103,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ async def test_async_step_user_with_found_devices_already_setup(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=KEGTRON_KT100_SERVICE_INFO,
|
data=KEGTRON_KT100_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=KEGTRON_KT100_SERVICE_INFO,
|
data=KEGTRON_KT100_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -161,7 +161,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=KEGTRON_KT100_SERVICE_INFO,
|
data=KEGTRON_KT100_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=KEGTRON_KT100_SERVICE_INFO,
|
data=KEGTRON_KT100_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -185,14 +185,14 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.kegtron.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
user_input={"address": "D0:CF:5E:5C:9B:75"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Kegtron KT-100 9B75"
|
assert result2["title"] == "Kegtron KT-100 9B75"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
assert result2["result"].unique_id == "D0:CF:5E:5C:9B:75"
|
||||||
|
|
|
@ -33,7 +33,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_BLUETOOTH},
|
context={"source": SOURCE_BLUETOOTH},
|
||||||
data=SERVICE_INFO,
|
data=SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
with patch_async_setup_entry() as mock_setup_entry, patch_microbot_api():
|
with patch_async_setup_entry() as mock_setup_entry, patch_microbot_api():
|
||||||
|
@ -43,7 +43,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ async def test_bluetooth_discovery_already_setup(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_BLUETOOTH},
|
context={"source": SOURCE_BLUETOOTH},
|
||||||
data=SERVICE_INFO,
|
data=SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "link"
|
assert result2["step_id"] == "link"
|
||||||
assert result2["errors"] is None
|
assert result2["errors"] is None
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["result"].data == {
|
assert result3["result"].data == {
|
||||||
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
|
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
|
||||||
CONF_ACCESS_TOKEN: ANY,
|
CONF_ACCESS_TOKEN: ANY,
|
||||||
|
@ -125,7 +125,7 @@ async def test_user_setup_already_configured(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ async def test_user_no_devices(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ async def test_no_link(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ async def test_no_link(hass: HomeAssistant) -> None:
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "link"
|
assert result2["step_id"] == "link"
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -183,7 +183,7 @@ async def test_no_link(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.FORM
|
assert result3["type"] is FlowResultType.FORM
|
||||||
assert result3["step_id"] == "link"
|
assert result3["step_id"] == "link"
|
||||||
assert result3["errors"] == {"base": "linking"}
|
assert result3["errors"] == {"base": "linking"}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.kitchen_sink import DOMAIN
|
from homeassistant.components.kitchen_sink import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ async def test_import_once(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={},
|
data={},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Kitchen Sink"
|
assert result["title"] == "Kitchen Sink"
|
||||||
assert result["data"] == {}
|
assert result["data"] == {}
|
||||||
assert result["options"] == {}
|
assert result["options"] == {}
|
||||||
|
@ -45,7 +46,7 @@ async def test_import_once(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
data={},
|
data={},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
mock_setup_entry.assert_not_called()
|
mock_setup_entry.assert_not_called()
|
||||||
|
|
||||||
|
@ -63,5 +64,5 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
|
@ -6,10 +6,11 @@ from unittest.mock import AsyncMock, Mock, patch
|
||||||
from aiohttp import ClientConnectorError, ClientResponseError
|
from aiohttp import ClientConnectorError, ClientResponseError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
|
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntryState
|
from homeassistant.config_entries import ConfigEntryState
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
@ -74,14 +75,14 @@ async def test_form_options(
|
||||||
assert config_entry.state is ConfigEntryState.LOADED
|
assert config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_REVERSE: True}
|
result["flow_id"], user_input={CONF_REVERSE: True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {CONF_REVERSE: True}
|
assert config_entry.options == {CONF_REVERSE: True}
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
|
@ -163,7 +163,7 @@ async def test_routing_setup(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -172,7 +172,7 @@ async def test_routing_setup(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "routing"
|
assert result2["step_id"] == "routing"
|
||||||
assert result2["errors"] == {"base": "no_router_discovered"}
|
assert result2["errors"] == {"base": "no_router_discovered"}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ async def test_routing_setup(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "Routing as 1.1.110"
|
assert result3["title"] == "Routing as 1.1.110"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -217,7 +217,7 @@ async def test_routing_setup_advanced(
|
||||||
"show_advanced_options": True,
|
"show_advanced_options": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -226,7 +226,7 @@ async def test_routing_setup_advanced(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "routing"
|
assert result2["step_id"] == "routing"
|
||||||
assert result2["errors"] == {"base": "no_router_discovered"}
|
assert result2["errors"] == {"base": "no_router_discovered"}
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ async def test_routing_setup_advanced(
|
||||||
CONF_KNX_LOCAL_IP: "no_local_ip",
|
CONF_KNX_LOCAL_IP: "no_local_ip",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result_invalid_input["type"] == FlowResultType.FORM
|
assert result_invalid_input["type"] is FlowResultType.FORM
|
||||||
assert result_invalid_input["step_id"] == "routing"
|
assert result_invalid_input["step_id"] == "routing"
|
||||||
assert result_invalid_input["errors"] == {
|
assert result_invalid_input["errors"] == {
|
||||||
CONF_KNX_MCAST_GRP: "invalid_ip_address",
|
CONF_KNX_MCAST_GRP: "invalid_ip_address",
|
||||||
|
@ -260,7 +260,7 @@ async def test_routing_setup_advanced(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "Routing as 1.1.110"
|
assert result3["title"] == "Routing as 1.1.110"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -288,7 +288,7 @@ async def test_routing_secure_manual_setup(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -297,7 +297,7 @@ async def test_routing_secure_manual_setup(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "routing"
|
assert result2["step_id"] == "routing"
|
||||||
assert result2["errors"] == {"base": "no_router_discovered"}
|
assert result2["errors"] == {"base": "no_router_discovered"}
|
||||||
|
|
||||||
|
@ -310,14 +310,14 @@ async def test_routing_secure_manual_setup(
|
||||||
CONF_KNX_ROUTING_SECURE: True,
|
CONF_KNX_ROUTING_SECURE: True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result3["type"] == FlowResultType.MENU
|
assert result3["type"] is FlowResultType.MENU
|
||||||
assert result3["step_id"] == "secure_key_source_menu_routing"
|
assert result3["step_id"] == "secure_key_source_menu_routing"
|
||||||
|
|
||||||
result4 = await hass.config_entries.flow.async_configure(
|
result4 = await hass.config_entries.flow.async_configure(
|
||||||
result3["flow_id"],
|
result3["flow_id"],
|
||||||
{"next_step_id": "secure_routing_manual"},
|
{"next_step_id": "secure_routing_manual"},
|
||||||
)
|
)
|
||||||
assert result4["type"] == FlowResultType.FORM
|
assert result4["type"] is FlowResultType.FORM
|
||||||
assert result4["step_id"] == "secure_routing_manual"
|
assert result4["step_id"] == "secure_routing_manual"
|
||||||
assert not result4["errors"]
|
assert not result4["errors"]
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ async def test_routing_secure_manual_setup(
|
||||||
CONF_KNX_ROUTING_SYNC_LATENCY_TOLERANCE: 2000,
|
CONF_KNX_ROUTING_SYNC_LATENCY_TOLERANCE: 2000,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result_invalid_key1["type"] == FlowResultType.FORM
|
assert result_invalid_key1["type"] is FlowResultType.FORM
|
||||||
assert result_invalid_key1["step_id"] == "secure_routing_manual"
|
assert result_invalid_key1["step_id"] == "secure_routing_manual"
|
||||||
assert result_invalid_key1["errors"] == {"backbone_key": "invalid_backbone_key"}
|
assert result_invalid_key1["errors"] == {"backbone_key": "invalid_backbone_key"}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ async def test_routing_secure_manual_setup(
|
||||||
CONF_KNX_ROUTING_SYNC_LATENCY_TOLERANCE: 2000,
|
CONF_KNX_ROUTING_SYNC_LATENCY_TOLERANCE: 2000,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result_invalid_key2["type"] == FlowResultType.FORM
|
assert result_invalid_key2["type"] is FlowResultType.FORM
|
||||||
assert result_invalid_key2["step_id"] == "secure_routing_manual"
|
assert result_invalid_key2["step_id"] == "secure_routing_manual"
|
||||||
assert result_invalid_key2["errors"] == {"backbone_key": "invalid_backbone_key"}
|
assert result_invalid_key2["errors"] == {"backbone_key": "invalid_backbone_key"}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ async def test_routing_secure_manual_setup(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert secure_routing_manual["type"] == FlowResultType.CREATE_ENTRY
|
assert secure_routing_manual["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert secure_routing_manual["title"] == "Secure Routing as 0.0.123"
|
assert secure_routing_manual["title"] == "Secure Routing as 0.0.123"
|
||||||
assert secure_routing_manual["data"] == {
|
assert secure_routing_manual["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -378,7 +378,7 @@ async def test_routing_secure_keyfile(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -387,7 +387,7 @@ async def test_routing_secure_keyfile(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_ROUTING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "routing"
|
assert result2["step_id"] == "routing"
|
||||||
assert result2["errors"] == {"base": "no_router_discovered"}
|
assert result2["errors"] == {"base": "no_router_discovered"}
|
||||||
|
|
||||||
|
@ -400,14 +400,14 @@ async def test_routing_secure_keyfile(
|
||||||
CONF_KNX_ROUTING_SECURE: True,
|
CONF_KNX_ROUTING_SECURE: True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result3["type"] == FlowResultType.MENU
|
assert result3["type"] is FlowResultType.MENU
|
||||||
assert result3["step_id"] == "secure_key_source_menu_routing"
|
assert result3["step_id"] == "secure_key_source_menu_routing"
|
||||||
|
|
||||||
result4 = await hass.config_entries.flow.async_configure(
|
result4 = await hass.config_entries.flow.async_configure(
|
||||||
result3["flow_id"],
|
result3["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result4["type"] == FlowResultType.FORM
|
assert result4["type"] is FlowResultType.FORM
|
||||||
assert result4["step_id"] == "secure_knxkeys"
|
assert result4["step_id"] == "secure_knxkeys"
|
||||||
assert not result4["errors"]
|
assert not result4["errors"]
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ async def test_routing_secure_keyfile(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert routing_secure_knxkeys["type"] == FlowResultType.CREATE_ENTRY
|
assert routing_secure_knxkeys["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert routing_secure_knxkeys["title"] == "Secure Routing as 0.0.123"
|
assert routing_secure_knxkeys["title"] == "Secure Routing as 0.0.123"
|
||||||
assert routing_secure_knxkeys["data"] == {
|
assert routing_secure_knxkeys["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -525,7 +525,7 @@ async def test_tunneling_setup_manual(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -534,7 +534,7 @@ async def test_tunneling_setup_manual(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "manual_tunnel"
|
assert result2["step_id"] == "manual_tunnel"
|
||||||
assert result2["errors"] == {"base": "no_tunnel_discovered"}
|
assert result2["errors"] == {"base": "no_tunnel_discovered"}
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ async def test_tunneling_setup_manual(
|
||||||
user_input,
|
user_input,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == title
|
assert result3["title"] == title
|
||||||
assert result3["data"] == config_entry_data
|
assert result3["data"] == config_entry_data
|
||||||
knx_setup.assert_called_once()
|
knx_setup.assert_called_once()
|
||||||
|
@ -682,7 +682,7 @@ async def test_tunneling_setup_manual_request_description_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Tunneling TCP @ 192.168.0.1"
|
assert result["title"] == "Tunneling TCP @ 192.168.0.1"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -716,7 +716,7 @@ async def test_tunneling_setup_for_local_ip(
|
||||||
"show_advanced_options": True,
|
"show_advanced_options": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -725,7 +725,7 @@ async def test_tunneling_setup_for_local_ip(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "manual_tunnel"
|
assert result2["step_id"] == "manual_tunnel"
|
||||||
assert result2["errors"] == {"base": "no_tunnel_discovered"}
|
assert result2["errors"] == {"base": "no_tunnel_discovered"}
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ async def test_tunneling_setup_for_local_ip(
|
||||||
CONF_KNX_LOCAL_IP: "192.168.1.112",
|
CONF_KNX_LOCAL_IP: "192.168.1.112",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result_invalid_host["type"] == FlowResultType.FORM
|
assert result_invalid_host["type"] is FlowResultType.FORM
|
||||||
assert result_invalid_host["step_id"] == "manual_tunnel"
|
assert result_invalid_host["step_id"] == "manual_tunnel"
|
||||||
assert result_invalid_host["errors"] == {
|
assert result_invalid_host["errors"] == {
|
||||||
CONF_HOST: "invalid_ip_address",
|
CONF_HOST: "invalid_ip_address",
|
||||||
|
@ -755,7 +755,7 @@ async def test_tunneling_setup_for_local_ip(
|
||||||
CONF_KNX_LOCAL_IP: "asdf",
|
CONF_KNX_LOCAL_IP: "asdf",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result_invalid_local["type"] == FlowResultType.FORM
|
assert result_invalid_local["type"] is FlowResultType.FORM
|
||||||
assert result_invalid_local["step_id"] == "manual_tunnel"
|
assert result_invalid_local["step_id"] == "manual_tunnel"
|
||||||
assert result_invalid_local["errors"] == {
|
assert result_invalid_local["errors"] == {
|
||||||
CONF_KNX_LOCAL_IP: "invalid_ip_address",
|
CONF_KNX_LOCAL_IP: "invalid_ip_address",
|
||||||
|
@ -773,7 +773,7 @@ async def test_tunneling_setup_for_local_ip(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "Tunneling UDP @ 192.168.0.2"
|
assert result3["title"] == "Tunneling UDP @ 192.168.0.2"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -804,7 +804,7 @@ async def test_tunneling_setup_for_multiple_found_gateways(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
tunnel_flow = await hass.config_entries.flow.async_configure(
|
tunnel_flow = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -813,7 +813,7 @@ async def test_tunneling_setup_for_multiple_found_gateways(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert tunnel_flow["type"] == FlowResultType.FORM
|
assert tunnel_flow["type"] is FlowResultType.FORM
|
||||||
assert tunnel_flow["step_id"] == "tunnel"
|
assert tunnel_flow["step_id"] == "tunnel"
|
||||||
assert not tunnel_flow["errors"]
|
assert not tunnel_flow["errors"]
|
||||||
|
|
||||||
|
@ -822,7 +822,7 @@ async def test_tunneling_setup_for_multiple_found_gateways(
|
||||||
{CONF_KNX_GATEWAY: str(gateway)},
|
{CONF_KNX_GATEWAY: str(gateway)},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
|
@ -859,7 +859,7 @@ async def test_manual_tunnel_step_with_found_gateway(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
tunnel_flow = await hass.config_entries.flow.async_configure(
|
tunnel_flow = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -868,7 +868,7 @@ async def test_manual_tunnel_step_with_found_gateway(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert tunnel_flow["type"] == FlowResultType.FORM
|
assert tunnel_flow["type"] is FlowResultType.FORM
|
||||||
assert tunnel_flow["step_id"] == "tunnel"
|
assert tunnel_flow["step_id"] == "tunnel"
|
||||||
assert not tunnel_flow["errors"]
|
assert not tunnel_flow["errors"]
|
||||||
|
|
||||||
|
@ -878,7 +878,7 @@ async def test_manual_tunnel_step_with_found_gateway(
|
||||||
CONF_KNX_GATEWAY: OPTION_MANUAL_TUNNEL,
|
CONF_KNX_GATEWAY: OPTION_MANUAL_TUNNEL,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert manual_tunnel_flow["type"] == FlowResultType.FORM
|
assert manual_tunnel_flow["type"] is FlowResultType.FORM
|
||||||
assert manual_tunnel_flow["step_id"] == "manual_tunnel"
|
assert manual_tunnel_flow["step_id"] == "manual_tunnel"
|
||||||
assert not manual_tunnel_flow["errors"]
|
assert not manual_tunnel_flow["errors"]
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ async def test_form_with_automatic_connection_handling(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -906,7 +906,7 @@ async def test_form_with_automatic_connection_handling(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == CONF_KNX_AUTOMATIC.capitalize()
|
assert result2["title"] == CONF_KNX_AUTOMATIC.capitalize()
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
# don't use **DEFAULT_ENTRY_DATA here to check for correct usage of defaults
|
# don't use **DEFAULT_ENTRY_DATA here to check for correct usage of defaults
|
||||||
|
@ -939,7 +939,7 @@ async def _get_menu_step_secure_tunnel(hass: HomeAssistant) -> FlowResult:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -948,7 +948,7 @@ async def _get_menu_step_secure_tunnel(hass: HomeAssistant) -> FlowResult:
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "tunnel"
|
assert result2["step_id"] == "tunnel"
|
||||||
assert not result2["errors"]
|
assert not result2["errors"]
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ async def _get_menu_step_secure_tunnel(hass: HomeAssistant) -> FlowResult:
|
||||||
result2["flow_id"],
|
result2["flow_id"],
|
||||||
{CONF_KNX_GATEWAY: str(gateway)},
|
{CONF_KNX_GATEWAY: str(gateway)},
|
||||||
)
|
)
|
||||||
assert result3["type"] == FlowResultType.MENU
|
assert result3["type"] is FlowResultType.MENU
|
||||||
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
||||||
return result3
|
return result3
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ async def test_get_secure_menu_step_manual_tunnelling(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -997,7 +997,7 @@ async def test_get_secure_menu_step_manual_tunnelling(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "tunnel"
|
assert result2["step_id"] == "tunnel"
|
||||||
assert not result2["errors"]
|
assert not result2["errors"]
|
||||||
|
|
||||||
|
@ -1016,7 +1016,7 @@ async def test_get_secure_menu_step_manual_tunnelling(
|
||||||
CONF_PORT: 3675,
|
CONF_PORT: 3675,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result3["type"] == FlowResultType.MENU
|
assert result3["type"] is FlowResultType.MENU
|
||||||
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ async def test_configure_secure_tunnel_manual(hass: HomeAssistant, knx_setup) ->
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_tunnel_manual"},
|
{"next_step_id": "secure_tunnel_manual"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_tunnel_manual"
|
assert result["step_id"] == "secure_tunnel_manual"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -1041,7 +1041,7 @@ async def test_configure_secure_tunnel_manual(hass: HomeAssistant, knx_setup) ->
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert secure_tunnel_manual["type"] == FlowResultType.CREATE_ENTRY
|
assert secure_tunnel_manual["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert secure_tunnel_manual["data"] == {
|
assert secure_tunnel_manual["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
||||||
|
@ -1066,7 +1066,7 @@ async def test_configure_secure_knxkeys(hass: HomeAssistant, knx_setup) -> None:
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_knxkeys"
|
assert result["step_id"] == "secure_knxkeys"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -1078,7 +1078,7 @@ async def test_configure_secure_knxkeys(hass: HomeAssistant, knx_setup) -> None:
|
||||||
CONF_KNX_KNXKEY_PASSWORD: "test",
|
CONF_KNX_KNXKEY_PASSWORD: "test",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert secure_knxkeys["step_id"] == "knxkeys_tunnel_select"
|
assert secure_knxkeys["step_id"] == "knxkeys_tunnel_select"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
secure_knxkeys = await hass.config_entries.flow.async_configure(
|
secure_knxkeys = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -1087,7 +1087,7 @@ async def test_configure_secure_knxkeys(hass: HomeAssistant, knx_setup) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert secure_knxkeys["type"] == FlowResultType.CREATE_ENTRY
|
assert secure_knxkeys["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert secure_knxkeys["data"] == {
|
assert secure_knxkeys["data"] == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
||||||
|
@ -1116,7 +1116,7 @@ async def test_configure_secure_knxkeys_invalid_signature(hass: HomeAssistant) -
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_knxkeys"
|
assert result["step_id"] == "secure_knxkeys"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -1130,7 +1130,7 @@ async def test_configure_secure_knxkeys_invalid_signature(hass: HomeAssistant) -
|
||||||
CONF_KNX_KNXKEY_PASSWORD: "password",
|
CONF_KNX_KNXKEY_PASSWORD: "password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert secure_knxkeys["type"] == FlowResultType.FORM
|
assert secure_knxkeys["type"] is FlowResultType.FORM
|
||||||
assert secure_knxkeys["errors"]
|
assert secure_knxkeys["errors"]
|
||||||
assert (
|
assert (
|
||||||
secure_knxkeys["errors"][CONF_KNX_KNXKEY_PASSWORD]
|
secure_knxkeys["errors"][CONF_KNX_KNXKEY_PASSWORD]
|
||||||
|
@ -1146,7 +1146,7 @@ async def test_configure_secure_knxkeys_no_tunnel_for_host(hass: HomeAssistant)
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_knxkeys"
|
assert result["step_id"] == "secure_knxkeys"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -1159,7 +1159,7 @@ async def test_configure_secure_knxkeys_no_tunnel_for_host(hass: HomeAssistant)
|
||||||
CONF_KNX_KNXKEY_PASSWORD: "password",
|
CONF_KNX_KNXKEY_PASSWORD: "password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert secure_knxkeys["type"] == FlowResultType.FORM
|
assert secure_knxkeys["type"] is FlowResultType.FORM
|
||||||
assert secure_knxkeys["errors"] == {"base": "keyfile_no_tunnel_for_host"}
|
assert secure_knxkeys["errors"] == {"base": "keyfile_no_tunnel_for_host"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ async def test_options_flow_connection_type(
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "connection_type"},
|
{"next_step_id": "connection_type"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "connection_type"
|
assert result["step_id"] == "connection_type"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1192,7 +1192,7 @@ async def test_options_flow_connection_type(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "tunnel"
|
assert result2["step_id"] == "tunnel"
|
||||||
|
|
||||||
result3 = await hass.config_entries.options.async_configure(
|
result3 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1202,7 +1202,7 @@ async def test_options_flow_connection_type(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert not result3["data"]
|
assert not result3["data"]
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
|
@ -1263,7 +1263,7 @@ async def test_options_flow_secure_manual_to_keyfile(
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "connection_type"},
|
{"next_step_id": "connection_type"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "connection_type"
|
assert result["step_id"] == "connection_type"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1272,7 +1272,7 @@ async def test_options_flow_secure_manual_to_keyfile(
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "tunnel"
|
assert result2["step_id"] == "tunnel"
|
||||||
assert not result2["errors"]
|
assert not result2["errors"]
|
||||||
|
|
||||||
|
@ -1280,14 +1280,14 @@ async def test_options_flow_secure_manual_to_keyfile(
|
||||||
result2["flow_id"],
|
result2["flow_id"],
|
||||||
{CONF_KNX_GATEWAY: str(gateway)},
|
{CONF_KNX_GATEWAY: str(gateway)},
|
||||||
)
|
)
|
||||||
assert result3["type"] == FlowResultType.MENU
|
assert result3["type"] is FlowResultType.MENU
|
||||||
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
assert result3["step_id"] == "secure_key_source_menu_tunnel"
|
||||||
|
|
||||||
result4 = await hass.config_entries.options.async_configure(
|
result4 = await hass.config_entries.options.async_configure(
|
||||||
result3["flow_id"],
|
result3["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result4["type"] == FlowResultType.FORM
|
assert result4["type"] is FlowResultType.FORM
|
||||||
assert result4["step_id"] == "secure_knxkeys"
|
assert result4["step_id"] == "secure_knxkeys"
|
||||||
assert not result4["errors"]
|
assert not result4["errors"]
|
||||||
|
|
||||||
|
@ -1299,7 +1299,7 @@ async def test_options_flow_secure_manual_to_keyfile(
|
||||||
CONF_KNX_KNXKEY_PASSWORD: "test",
|
CONF_KNX_KNXKEY_PASSWORD: "test",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert secure_knxkeys["step_id"] == "knxkeys_tunnel_select"
|
assert secure_knxkeys["step_id"] == "knxkeys_tunnel_select"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
secure_knxkeys = await hass.config_entries.options.async_configure(
|
secure_knxkeys = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1308,7 +1308,7 @@ async def test_options_flow_secure_manual_to_keyfile(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert secure_knxkeys["type"] == FlowResultType.CREATE_ENTRY
|
assert secure_knxkeys["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
CONF_KNX_CONNECTION_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
|
||||||
|
@ -1341,7 +1341,7 @@ async def test_options_communication_settings(
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "communication_settings"},
|
{"next_step_id": "communication_settings"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "communication_settings"
|
assert result["step_id"] == "communication_settings"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1353,7 +1353,7 @@ async def test_options_communication_settings(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert not result2.get("data")
|
assert not result2.get("data")
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
**DEFAULT_ENTRY_DATA,
|
**DEFAULT_ENTRY_DATA,
|
||||||
|
@ -1394,7 +1394,7 @@ async def test_options_update_keyfile(hass: HomeAssistant, knx_setup) -> None:
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_knxkeys"
|
assert result["step_id"] == "secure_knxkeys"
|
||||||
|
|
||||||
with patch_file_upload():
|
with patch_file_upload():
|
||||||
|
@ -1406,7 +1406,7 @@ async def test_options_update_keyfile(hass: HomeAssistant, knx_setup) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert not result2.get("data")
|
assert not result2.get("data")
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
**start_data,
|
**start_data,
|
||||||
|
@ -1442,7 +1442,7 @@ async def test_options_keyfile_upload(hass: HomeAssistant, knx_setup) -> None:
|
||||||
menu_step["flow_id"],
|
menu_step["flow_id"],
|
||||||
{"next_step_id": "secure_knxkeys"},
|
{"next_step_id": "secure_knxkeys"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "secure_knxkeys"
|
assert result["step_id"] == "secure_knxkeys"
|
||||||
|
|
||||||
with patch_file_upload():
|
with patch_file_upload():
|
||||||
|
@ -1454,7 +1454,7 @@ async def test_options_keyfile_upload(hass: HomeAssistant, knx_setup) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "knxkeys_tunnel_select"
|
assert result2["step_id"] == "knxkeys_tunnel_select"
|
||||||
|
|
||||||
result3 = await hass.config_entries.options.async_configure(
|
result3 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1464,7 +1464,7 @@ async def test_options_keyfile_upload(hass: HomeAssistant, knx_setup) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert not result3.get("data")
|
assert not result3.get("data")
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
**start_data,
|
**start_data,
|
||||||
|
|
|
@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -42,7 +42,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "location"
|
assert result2["step_id"] == "location"
|
||||||
assert result2["errors"] is None
|
assert result2["errors"] is None
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "Test"
|
assert result3["title"] == "Test"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
"username": "test-username",
|
"username": "test-username",
|
||||||
|
@ -83,7 +83,7 @@ async def test_form_auth_false(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ async def test_form_login_first(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ async def test_form_no_locations(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "no_locations"}
|
assert result2["errors"] == {"base": "no_locations"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ async def test_already_configured_device(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -218,7 +218,7 @@ async def test_already_configured_device(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "location"
|
assert result2["step_id"] == "location"
|
||||||
assert result2["errors"] is None
|
assert result2["errors"] is None
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ async def test_already_configured_device(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "already_configured"
|
assert result3["reason"] == "already_configured"
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
data=data,
|
data=data,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
new_username = "new-username"
|
new_username = "new-username"
|
||||||
|
@ -283,7 +283,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
|
|
||||||
assert len(hass.config_entries.async_entries()) == 1
|
assert len(hass.config_entries.async_entries()) == 1
|
||||||
|
|
|
@ -30,7 +30,7 @@ async def __do_successful_user_step(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "machine_selection"
|
assert result2["step_id"] == "machine_selection"
|
||||||
return result2
|
return result2
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ async def __do_sucessful_machine_selection_step(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
assert result3["title"] == mock_lamarzocco.serial_number
|
assert result3["title"] == mock_lamarzocco.serial_number
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
|
@ -63,7 +63,7 @@ async def test_form(hass: HomeAssistant, mock_lamarzocco: MagicMock) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ async def test_form_abort_already_configured(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -91,7 +91,7 @@ async def test_form_abort_already_configured(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "machine_selection"
|
assert result2["step_id"] == "machine_selection"
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -103,7 +103,7 @@ async def test_form_abort_already_configured(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "already_configured"
|
assert result3["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ async def test_form_invalid_auth(
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ async def test_form_invalid_host(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -150,7 +150,7 @@ async def test_form_invalid_host(
|
||||||
|
|
||||||
mock_lamarzocco.check_local_connection.return_value = False
|
mock_lamarzocco.check_local_connection.return_value = False
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "machine_selection"
|
assert result2["step_id"] == "machine_selection"
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -162,7 +162,7 @@ async def test_form_invalid_host(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.FORM
|
assert result3["type"] is FlowResultType.FORM
|
||||||
assert result3["errors"] == {"host": "cannot_connect"}
|
assert result3["errors"] == {"host": "cannot_connect"}
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ async def test_form_cannot_connect(
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "no_machines"}
|
assert result2["errors"] == {"base": "no_machines"}
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ async def test_form_cannot_connect(
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 2
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 2
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ async def test_reauth_flow(
|
||||||
data=mock_config_entry.data,
|
data=mock_config_entry.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -232,7 +232,7 @@ async def test_reauth_flow(
|
||||||
{CONF_PASSWORD: "new_password"},
|
{CONF_PASSWORD: "new_password"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
@ -250,14 +250,14 @@ async def test_bluetooth_discovery(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_BLUETOOTH}, data=service_info
|
DOMAIN, context={"source": config_entries.SOURCE_BLUETOOTH}, data=service_info
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "machine_selection"
|
assert result2["step_id"] == "machine_selection"
|
||||||
|
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
@ -269,7 +269,7 @@ async def test_bluetooth_discovery(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
assert result3["title"] == mock_lamarzocco.serial_number
|
assert result3["title"] == mock_lamarzocco.serial_number
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
|
@ -296,7 +296,7 @@ async def test_bluetooth_discovery_errors(
|
||||||
data=service_info,
|
data=service_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
mock_lamarzocco.get_all_machines.return_value = [("GS98765", "GS3 MP")]
|
mock_lamarzocco.get_all_machines.return_value = [("GS98765", "GS3 MP")]
|
||||||
|
@ -304,7 +304,7 @@ async def test_bluetooth_discovery_errors(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "machine_not_found"}
|
assert result2["errors"] == {"base": "machine_not_found"}
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ async def test_bluetooth_discovery_errors(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "machine_selection"
|
assert result2["step_id"] == "machine_selection"
|
||||||
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 2
|
assert len(mock_lamarzocco.get_all_machines.mock_calls) == 2
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ async def test_bluetooth_discovery_errors(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
assert result3["title"] == mock_lamarzocco.serial_number
|
assert result3["title"] == mock_lamarzocco.serial_number
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
|
@ -350,7 +350,7 @@ async def test_options_flow(
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -361,7 +361,7 @@ async def test_options_flow(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_USE_BLUETOOTH: False,
|
CONF_USE_BLUETOOTH: False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ async def test_full_cloud_import_flow_multiple_devices(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.MENU
|
assert result.get("type") is FlowResultType.MENU
|
||||||
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
||||||
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
||||||
flow_id = result["flow_id"]
|
flow_id = result["flow_id"]
|
||||||
|
@ -77,7 +77,7 @@ async def test_full_cloud_import_flow_multiple_devices(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.EXTERNAL_STEP
|
assert result2.get("type") is FlowResultType.EXTERNAL_STEP
|
||||||
assert result2.get("url") == (
|
assert result2.get("url") == (
|
||||||
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
||||||
"?response_type=code&client_id=client"
|
"?response_type=code&client_id=client"
|
||||||
|
@ -103,14 +103,14 @@ async def test_full_cloud_import_flow_multiple_devices(
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.FORM
|
assert result3.get("type") is FlowResultType.FORM
|
||||||
assert result3.get("step_id") == "cloud_select_device"
|
assert result3.get("step_id") == "cloud_select_device"
|
||||||
|
|
||||||
result4 = await hass.config_entries.flow.async_configure(
|
result4 = await hass.config_entries.flow.async_configure(
|
||||||
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result4.get("type") == FlowResultType.CREATE_ENTRY
|
assert result4.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result4.get("title") == "Frenck's LaMetric"
|
assert result4.get("title") == "Frenck's LaMetric"
|
||||||
assert result4.get("data") == {
|
assert result4.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -140,7 +140,7 @@ async def test_full_cloud_import_flow_single_device(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.MENU
|
assert result.get("type") is FlowResultType.MENU
|
||||||
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
||||||
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
||||||
flow_id = result["flow_id"]
|
flow_id = result["flow_id"]
|
||||||
|
@ -157,7 +157,7 @@ async def test_full_cloud_import_flow_single_device(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.EXTERNAL_STEP
|
assert result2.get("type") is FlowResultType.EXTERNAL_STEP
|
||||||
assert result2.get("url") == (
|
assert result2.get("url") == (
|
||||||
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
||||||
"?response_type=code&client_id=client"
|
"?response_type=code&client_id=client"
|
||||||
|
@ -188,7 +188,7 @@ async def test_full_cloud_import_flow_single_device(
|
||||||
]
|
]
|
||||||
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -214,7 +214,7 @@ async def test_full_manual(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.MENU
|
assert result.get("type") is FlowResultType.MENU
|
||||||
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
||||||
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
||||||
flow_id = result["flow_id"]
|
flow_id = result["flow_id"]
|
||||||
|
@ -223,14 +223,14 @@ async def test_full_manual(
|
||||||
flow_id, user_input={"next_step_id": "manual_entry"}
|
flow_id, user_input={"next_step_id": "manual_entry"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "manual_entry"
|
assert result2.get("step_id") == "manual_entry"
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -263,7 +263,7 @@ async def test_full_ssdp_with_cloud_import(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.MENU
|
assert result.get("type") is FlowResultType.MENU
|
||||||
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
||||||
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
||||||
flow_id = result["flow_id"]
|
flow_id = result["flow_id"]
|
||||||
|
@ -280,7 +280,7 @@ async def test_full_ssdp_with_cloud_import(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.EXTERNAL_STEP
|
assert result2.get("type") is FlowResultType.EXTERNAL_STEP
|
||||||
assert result2.get("url") == (
|
assert result2.get("url") == (
|
||||||
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
"https://developer.lametric.com/api/v2/oauth2/authorize"
|
||||||
"?response_type=code&client_id=client"
|
"?response_type=code&client_id=client"
|
||||||
|
@ -306,7 +306,7 @@ async def test_full_ssdp_with_cloud_import(
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
result3 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -332,7 +332,7 @@ async def test_full_ssdp_manual_entry(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.MENU
|
assert result.get("type") is FlowResultType.MENU
|
||||||
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
assert result.get("step_id") == "choice_enter_manual_or_fetch_cloud"
|
||||||
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
assert result.get("menu_options") == ["pick_implementation", "manual_entry"]
|
||||||
flow_id = result["flow_id"]
|
flow_id = result["flow_id"]
|
||||||
|
@ -341,14 +341,14 @@ async def test_full_ssdp_manual_entry(
|
||||||
flow_id, user_input={"next_step_id": "manual_entry"}
|
flow_id, user_input={"next_step_id": "manual_entry"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "manual_entry"
|
assert result2.get("step_id") == "manual_entry"
|
||||||
|
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -390,7 +390,7 @@ async def test_ssdp_abort_invalid_discovery(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=data
|
DOMAIN, context={"source": SOURCE_SSDP}, data=data
|
||||||
)
|
)
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == reason
|
assert result.get("reason") == reason
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ async def test_cloud_import_updates_existing_entry(
|
||||||
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "already_configured"
|
assert result2.get("reason") == "already_configured"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -473,7 +473,7 @@ async def test_manual_updates_existing_entry(
|
||||||
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.ABORT
|
assert result3.get("type") is FlowResultType.ABORT
|
||||||
assert result3.get("reason") == "already_configured"
|
assert result3.get("reason") == "already_configured"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -495,7 +495,7 @@ async def test_discovery_updates_existing_entry(
|
||||||
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DISCOVERY_INFO
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -544,7 +544,7 @@ async def test_cloud_abort_no_devices(
|
||||||
mock_lametric_cloud.devices.return_value = []
|
mock_lametric_cloud.devices.return_value = []
|
||||||
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "no_devices"
|
assert result2.get("reason") == "no_devices"
|
||||||
|
|
||||||
assert len(mock_lametric_cloud.devices.mock_calls) == 1
|
assert len(mock_lametric_cloud.devices.mock_calls) == 1
|
||||||
|
@ -581,7 +581,7 @@ async def test_manual_errors(
|
||||||
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "manual_entry"
|
assert result2.get("step_id") == "manual_entry"
|
||||||
assert result2.get("errors") == {"base": reason}
|
assert result2.get("errors") == {"base": reason}
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ async def test_manual_errors(
|
||||||
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_HOST: "127.0.0.1", CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -664,7 +664,7 @@ async def test_cloud_errors(
|
||||||
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "cloud_select_device"
|
assert result2.get("step_id") == "cloud_select_device"
|
||||||
assert result2.get("errors") == {"base": reason}
|
assert result2.get("errors") == {"base": reason}
|
||||||
|
|
||||||
|
@ -678,7 +678,7 @@ async def test_cloud_errors(
|
||||||
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
flow_id, user_input={CONF_DEVICE: "SA110405124500W00BS9"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Frenck's LaMetric"
|
assert result3.get("title") == "Frenck's LaMetric"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -711,7 +711,7 @@ async def test_dhcp_discovery_updates_entry(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_API_KEY: "mock-from-fixture",
|
CONF_API_KEY: "mock-from-fixture",
|
||||||
|
@ -737,7 +737,7 @@ async def test_dhcp_unknown_device(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "unknown"
|
assert result.get("reason") == "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
@ -791,7 +791,7 @@ async def test_reauth_cloud_import(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "reauth_successful"
|
assert result2.get("reason") == "reauth_successful"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -855,7 +855,7 @@ async def test_reauth_cloud_abort_device_not_found(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
result2 = await hass.config_entries.flow.async_configure(flow_id)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "reauth_device_not_found"
|
assert result2.get("reason") == "reauth_device_not_found"
|
||||||
|
|
||||||
assert len(mock_lametric_cloud.devices.mock_calls) == 1
|
assert len(mock_lametric_cloud.devices.mock_calls) == 1
|
||||||
|
@ -892,7 +892,7 @@ async def test_reauth_manual(
|
||||||
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "reauth_successful"
|
assert result2.get("reason") == "reauth_successful"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
@ -934,7 +934,7 @@ async def test_reauth_manual_sky(
|
||||||
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
flow_id, user_input={CONF_API_KEY: "mock-api-key"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "reauth_successful"
|
assert result2.get("reason") == "reauth_successful"
|
||||||
assert mock_config_entry.data == {
|
assert mock_config_entry.data == {
|
||||||
CONF_HOST: "127.0.0.1",
|
CONF_HOST: "127.0.0.1",
|
||||||
|
|
|
@ -49,7 +49,7 @@ async def test_manual_entry(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ async def test_manual_entry(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], {"device": "Enter Manually"}
|
result["flow_id"], {"device": "Enter Manually"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "setup_serial_manual_path"
|
assert result["step_id"] == "setup_serial_manual_path"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ async def test_manual_entry(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "LUGCUH50"
|
assert result["title"] == "LUGCUH50"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"device": "/dev/ttyUSB0",
|
"device": "/dev/ttyUSB0",
|
||||||
|
@ -85,14 +85,14 @@ async def test_list_entry(mock_port, mock_heat_meter, hass: HomeAssistant) -> No
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"device": port.device}
|
result["flow_id"], {"device": port.device}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "LUGCUH50"
|
assert result["title"] == "LUGCUH50"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"device": port.device,
|
"device": port.device,
|
||||||
|
@ -110,7 +110,7 @@ async def test_manual_entry_fail(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ async def test_manual_entry_fail(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], {"device": "Enter Manually"}
|
result["flow_id"], {"device": "Enter Manually"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "setup_serial_manual_path"
|
assert result["step_id"] == "setup_serial_manual_path"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ async def test_manual_entry_fail(mock_heat_meter, hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "setup_serial_manual_path"
|
assert result["step_id"] == "setup_serial_manual_path"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -142,14 +142,14 @@ async def test_list_entry_fail(mock_port, mock_heat_meter, hass: HomeAssistant)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"device": port.device}
|
result["flow_id"], {"device": port.device}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -185,5 +185,5 @@ async def test_already_configured(
|
||||||
result["flow_id"], {"device": port.device}
|
result["flow_id"], {"device": port.device}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -5,7 +5,6 @@ from unittest.mock import patch
|
||||||
from pylast import WSError
|
from pylast import WSError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.lastfm.const import (
|
from homeassistant.components.lastfm.const import (
|
||||||
CONF_MAIN_USER,
|
CONF_MAIN_USER,
|
||||||
CONF_USERS,
|
CONF_USERS,
|
||||||
|
@ -15,6 +14,7 @@ from homeassistant.components.lastfm.const import (
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
API_KEY,
|
API_KEY,
|
||||||
|
@ -42,14 +42,14 @@ async def test_full_user_flow(hass: HomeAssistant, default_user: MockUser) -> No
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_USER_DATA,
|
user_input=CONF_USER_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
assert result["step_id"] == "friends"
|
assert result["step_id"] == "friends"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == DEFAULT_NAME
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["options"] == CONF_DATA
|
assert result["options"] == CONF_DATA
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ async def test_flow_fails(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=CONF_USER_DATA
|
DOMAIN, context={"source": SOURCE_USER}, data=CONF_USER_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == message
|
assert result["errors"]["base"] == message
|
||||||
|
|
||||||
|
@ -87,14 +87,14 @@ async def test_flow_fails(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_USER_DATA,
|
user_input=CONF_USER_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
assert result["step_id"] == "friends"
|
assert result["step_id"] == "friends"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == DEFAULT_NAME
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["options"] == CONF_DATA
|
assert result["options"] == CONF_DATA
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ async def test_flow_friends_invalid_username(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_USER_DATA,
|
user_input=CONF_USER_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "friends"
|
assert result["step_id"] == "friends"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -124,7 +124,7 @@ async def test_flow_friends_invalid_username(
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "friends"
|
assert result["step_id"] == "friends"
|
||||||
assert result["errors"]["base"] == "invalid_account"
|
assert result["errors"]["base"] == "invalid_account"
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ async def test_flow_friends_invalid_username(
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
result["flow_id"], user_input=CONF_FRIENDS_DATA
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == DEFAULT_NAME
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["options"] == CONF_DATA
|
assert result["options"] == CONF_DATA
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ async def test_flow_friends_no_friends(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_USER_DATA,
|
user_input=CONF_USER_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "friends"
|
assert result["step_id"] == "friends"
|
||||||
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ async def test_options_flow(
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -180,7 +180,7 @@ async def test_options_flow(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_API_KEY: API_KEY,
|
CONF_API_KEY: API_KEY,
|
||||||
CONF_MAIN_USER: USERNAME_1,
|
CONF_MAIN_USER: USERNAME_1,
|
||||||
|
@ -201,7 +201,7 @@ async def test_options_flow_incorrect_username(
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -216,7 +216,7 @@ async def test_options_flow_incorrect_username(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert result["errors"]["base"] == "invalid_account"
|
assert result["errors"]["base"] == "invalid_account"
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ async def test_options_flow_incorrect_username(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_API_KEY: API_KEY,
|
CONF_API_KEY: API_KEY,
|
||||||
CONF_MAIN_USER: USERNAME_1,
|
CONF_MAIN_USER: USERNAME_1,
|
||||||
|
@ -248,7 +248,7 @@ async def test_options_flow_from_import(
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
||||||
|
|
||||||
|
@ -266,6 +266,6 @@ async def test_options_flow_without_friends(
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
assert len(result["data_schema"].schema[CONF_USERS].config["options"]) == 0
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.launch_library.const import DOMAIN
|
from homeassistant.components.launch_library.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -28,7 +28,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result.get("result").data == {}
|
assert result.get("result").data == {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,5 +44,5 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={}
|
DOMAIN, context={"source": SOURCE_USER}, data={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "single_instance_allowed"
|
assert result.get("reason") == "single_instance_allowed"
|
||||||
|
|
|
@ -17,7 +17,7 @@ async def test_form(hass: HomeAssistant, laundrify_setup_entry) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -26,7 +26,7 @@ async def test_form(hass: HomeAssistant, laundrify_setup_entry) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == DOMAIN
|
assert result["title"] == DOMAIN
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_ACCESS_TOKEN: VALID_ACCESS_TOKEN,
|
CONF_ACCESS_TOKEN: VALID_ACCESS_TOKEN,
|
||||||
|
@ -46,7 +46,7 @@ async def test_form_invalid_format(
|
||||||
data={CONF_CODE: "invalidFormat"},
|
data={CONF_CODE: "invalidFormat"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {CONF_CODE: "invalid_format"}
|
assert result["errors"] == {CONF_CODE: "invalid_format"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, laundrify_exchange_code) -
|
||||||
data=VALID_USER_INPUT,
|
data=VALID_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {CONF_CODE: "invalid_auth"}
|
assert result["errors"] == {CONF_CODE: "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ async def test_form_cannot_connect(
|
||||||
data=VALID_USER_INPUT,
|
data=VALID_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ async def test_form_unkown_exception(
|
||||||
data=VALID_USER_INPUT,
|
data=VALID_USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ async def test_step_reauth(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_REAUTH}
|
DOMAIN, context={"source": SOURCE_REAUTH}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -108,7 +108,7 @@ async def test_step_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
|
|
||||||
async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||||
|
@ -125,5 +125,5 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
from pypck.connection import PchkAuthenticationError, PchkLicenseError
|
from pypck.connection import PchkAuthenticationError, PchkLicenseError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.lcn.const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
|
from homeassistant.components.lcn.const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICES,
|
CONF_DEVICES,
|
||||||
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ async def test_step_import(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "pchk"
|
assert result["title"] == "pchk"
|
||||||
assert result["data"] == IMPORT_DATA
|
assert result["data"] == IMPORT_DATA
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ async def test_step_import_existing_host(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# Check if config entry was updated
|
# Check if config entry was updated
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "existing_configuration_updated"
|
assert result["reason"] == "existing_configuration_updated"
|
||||||
assert mock_entry.source == config_entries.SOURCE_IMPORT
|
assert mock_entry.source == config_entries.SOURCE_IMPORT
|
||||||
assert mock_entry.data == IMPORT_DATA
|
assert mock_entry.data == IMPORT_DATA
|
||||||
|
@ -95,5 +96,5 @@ async def test_step_import_error(hass: HomeAssistant, error, reason) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == reason
|
assert result["reason"] == reason
|
||||||
|
|
|
@ -24,7 +24,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
assert result2["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -63,7 +63,7 @@ async def test_user_step_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ async def test_user_step_no_new_devices_found(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
assert result3["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -152,7 +152,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
assert result3["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -205,7 +205,7 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=LD2410_BLE_DISCOVERY_INFO,
|
data=LD2410_BLE_DISCOVERY_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
assert result2["title"] == LD2410_BLE_DISCOVERY_INFO.name
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LD2410_BLE_DISCOVERY_INFO.address,
|
||||||
|
|
|
@ -18,7 +18,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
with patch("homeassistant.components.leaone.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.leaone.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "5F:5A:5C:52:D3:94"},
|
user_input={"address": "5F:5A:5C:52:D3:94"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "TZC4 D394"
|
assert result2["title"] == "TZC4 D394"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "5F:5A:5C:52:D3:94"
|
assert result2["result"].unique_id == "5F:5A:5C:52:D3:94"
|
||||||
|
@ -55,7 +55,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
@ -69,7 +69,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "5F:5A:5C:52:D3:94"},
|
user_input={"address": "5F:5A:5C:52:D3:94"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,5 +91,5 @@ async def test_async_step_user_with_found_devices_already_setup(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
|
@ -28,7 +28,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == LED_BLE_DISCOVERY_INFO.name
|
assert result2["title"] == LED_BLE_DISCOVERY_INFO.name
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -67,7 +67,7 @@ async def test_user_step_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ async def test_user_step_no_new_devices_found(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ async def test_user_step_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == LED_BLE_DISCOVERY_INFO.name
|
assert result3["title"] == LED_BLE_DISCOVERY_INFO.name
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -156,7 +156,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ async def test_user_step_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == LED_BLE_DISCOVERY_INFO.name
|
assert result3["title"] == LED_BLE_DISCOVERY_INFO.name
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -209,7 +209,7 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=LED_BLE_DISCOVERY_INFO,
|
data=LED_BLE_DISCOVERY_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == LED_BLE_DISCOVERY_INFO.name
|
assert result2["title"] == LED_BLE_DISCOVERY_INFO.name
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
CONF_ADDRESS: LED_BLE_DISCOVERY_INFO.address,
|
||||||
|
@ -246,5 +246,5 @@ async def test_bluetooth_unsupported_model(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=UNSUPPORTED_LED_BLE_DISCOVERY_INFO,
|
data=UNSUPPORTED_LED_BLE_DISCOVERY_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
|
|
@ -16,14 +16,14 @@ async def test_flow_user_form(hass: HomeAssistant, connection) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USER},
|
context={CONF_SOURCE: SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=MOCK_INPUT,
|
user_input=MOCK_INPUT,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == DEFAULT_NAME
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["data"] == CONF_DATA
|
assert result["data"] == CONF_DATA
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ async def test_flow_user_invalid_auth(hass: HomeAssistant, invalid_auth) -> None
|
||||||
context={CONF_SOURCE: SOURCE_USER},
|
context={CONF_SOURCE: SOURCE_USER},
|
||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "invalid_auth"
|
assert result["errors"]["base"] == "invalid_auth"
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant, cannot_connect) ->
|
||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "cannot_connect"
|
assert result["errors"]["base"] == "cannot_connect"
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ async def test_wrong_app(hass: HomeAssistant, wrong_app) -> None:
|
||||||
data=MOCK_INPUT,
|
data=MOCK_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "wrong_app"
|
assert result["errors"]["base"] == "wrong_app"
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ async def test_zeroconf_failed(hass: HomeAssistant, zeroconf_failed) -> None:
|
||||||
data=MOCK_INPUT,
|
data=MOCK_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "zeroconf_failed"
|
assert result["errors"]["base"] == "zeroconf_failed"
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant, unknown) -> None:
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_DATA,
|
user_input=CONF_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "unknown"
|
assert result["errors"]["base"] == "unknown"
|
||||||
|
|
||||||
|
@ -109,18 +109,18 @@ async def test_flow_reauth(
|
||||||
},
|
},
|
||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={},
|
user_input={},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_API_KEY: "abc123"},
|
user_input={CONF_API_KEY: "abc123"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert entry.data[CONF_API_KEY] == "abc123"
|
assert entry.data[CONF_API_KEY] == "abc123"
|
||||||
|
|
|
@ -353,7 +353,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
||||||
data={CONF_HOST: IP_ADDRESS, CONF_SERIAL: SERIAL},
|
data={CONF_HOST: IP_ADDRESS, CONF_SERIAL: SERIAL},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with _patch_discovery(), _patch_config_flow_try_connect():
|
with _patch_discovery(), _patch_config_flow_try_connect():
|
||||||
|
@ -365,7 +365,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_in_progress"
|
assert result2["reason"] == "already_in_progress"
|
||||||
|
|
||||||
with _patch_discovery(), _patch_config_flow_try_connect():
|
with _patch_discovery(), _patch_config_flow_try_connect():
|
||||||
|
@ -377,7 +377,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "already_in_progress"
|
assert result3["reason"] == "already_in_progress"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -392,7 +392,7 @@ async def test_discovered_by_discovery_and_dhcp(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "cannot_connect"
|
assert result3["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ async def test_discovered_by_dhcp_or_discovery(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -496,7 +496,7 @@ async def test_discovered_by_dhcp_or_discovery_failed_to_get_device(
|
||||||
DOMAIN, context={"source": source}, data=data
|
DOMAIN, context={"source": source}, data=data
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -538,7 +538,7 @@ async def test_discovered_by_dhcp_or_homekit_updates_ip(
|
||||||
data=data,
|
data=data,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert config_entry.data[CONF_HOST] == IP_ADDRESS
|
assert config_entry.data[CONF_HOST] == IP_ADDRESS
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -56,7 +56,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "test-site-name"
|
assert result3["title"] == "test-site-name"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
"email": "test-email",
|
"email": "test-email",
|
||||||
|
@ -86,7 +86,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
assert result1["type"] == FlowResultType.FORM
|
assert result1["type"] is FlowResultType.FORM
|
||||||
assert result1["step_id"] == "user"
|
assert result1["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -116,7 +116,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
|
|
||||||
entries = hass.config_entries.async_entries()
|
entries = hass.config_entries.async_entries()
|
||||||
|
@ -153,7 +153,7 @@ async def test_form_invalid_login(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,5 +176,5 @@ async def test_form_exception(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
|
@ -4,10 +4,11 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.litejet.const import CONF_DEFAULT_TRANSITION, DOMAIN
|
from homeassistant.components.litejet.const import CONF_DEFAULT_TRANSITION, DOMAIN
|
||||||
from homeassistant.const import CONF_PORT
|
from homeassistant.const import CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -83,5 +84,5 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_DEFAULT_TRANSITION: 12},
|
user_input={CONF_DEFAULT_TRANSITION: 12},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {CONF_DEFAULT_TRANSITION: 12}
|
assert result["data"] == {CONF_DEFAULT_TRANSITION: 12}
|
||||||
|
|
|
@ -134,7 +134,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_account: Account) -> None:
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -151,7 +151,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_account: Account) -> None:
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, mock_account: Account) ->
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -186,7 +186,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, mock_account: Account) ->
|
||||||
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -203,6 +203,6 @@ async def test_step_reauth_failed(hass: HomeAssistant, mock_account: Account) ->
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
user_input={CONF_PASSWORD: CONFIG[litterrobot.DOMAIN][CONF_PASSWORD]},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
|
@ -5,10 +5,10 @@ from unittest.mock import patch
|
||||||
from aiolivisi import errors as livisi_errors
|
from aiolivisi import errors as livisi_errors
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.livisi.const import DOMAIN
|
from homeassistant.components.livisi.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
|
@ -30,7 +30,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "SHC Classic"
|
assert result["title"] == "SHC Classic"
|
||||||
assert result["data"]["host"] == "1.1.1.1"
|
assert result["data"]["host"] == "1.1.1.1"
|
||||||
assert result["data"]["password"] == "test"
|
assert result["data"]["password"] == "test"
|
||||||
|
@ -59,11 +59,11 @@ async def test_create_entity_after_login_error(
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], VALID_CONFIG
|
result["flow_id"], VALID_CONFIG
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"]["base"] == expected_reason
|
assert result["errors"]["base"] == expected_reason
|
||||||
with mocked_livisi_login(), mocked_livisi_controller(), mocked_livisi_setup_entry():
|
with mocked_livisi_login(), mocked_livisi_controller(), mocked_livisi_setup_entry():
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=VALID_CONFIG,
|
user_input=VALID_CONFIG,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -34,7 +34,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "My Calendar"
|
assert result2["title"] == "My Calendar"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_CALENDAR_NAME: "My Calendar",
|
CONF_CALENDAR_NAME: "My Calendar",
|
||||||
|
@ -51,7 +51,7 @@ async def test_duplicate_name(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result.get("errors")
|
assert not result.get("errors")
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -63,5 +63,5 @@ async def test_duplicate_name(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.local_ip.const import DOMAIN
|
from homeassistant.components.local_ip.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@ async def test_config_flow(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get(f"sensor.{DOMAIN}")
|
state = hass.states.get(f"sensor.{DOMAIN}")
|
||||||
|
@ -36,5 +36,5 @@ async def test_already_setup(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -21,7 +21,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result.get("errors")
|
assert not result.get("errors")
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -32,7 +32,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == TODO_NAME
|
assert result2["title"] == TODO_NAME
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"todo_list_name": TODO_NAME,
|
"todo_list_name": TODO_NAME,
|
||||||
|
@ -49,7 +49,7 @@ async def test_duplicate_todo_list_name(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result.get("errors")
|
assert not result.get("errors")
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -61,5 +61,5 @@ async def test_duplicate_todo_list_name(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
|
@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.http import KEY_HASS
|
from homeassistant.components.http import KEY_HASS
|
||||||
from homeassistant.components.logi_circle import config_flow
|
from homeassistant.components.logi_circle import config_flow
|
||||||
from homeassistant.components.logi_circle.config_flow import (
|
from homeassistant.components.logi_circle.config_flow import (
|
||||||
|
@ -15,6 +15,7 @@ from homeassistant.components.logi_circle.config_flow import (
|
||||||
LogiCircleAuthCallbackView,
|
LogiCircleAuthCallbackView,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import AbortFlow, FlowResultType
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -67,7 +68,7 @@ async def test_step_import(hass: HomeAssistant, mock_logi_circle) -> None:
|
||||||
flow = init_config_flow(hass)
|
flow = init_config_flow(hass)
|
||||||
|
|
||||||
result = await flow.async_step_import()
|
result = await flow.async_step_import()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "auth"
|
assert result["step_id"] == "auth"
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,18 +86,18 @@ async def test_full_flow_implementation(hass: HomeAssistant, mock_logi_circle) -
|
||||||
flow = init_config_flow(hass)
|
flow = init_config_flow(hass)
|
||||||
|
|
||||||
result = await flow.async_step_user()
|
result = await flow.async_step_user()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await flow.async_step_user({"flow_impl": "test-other"})
|
result = await flow.async_step_user({"flow_impl": "test-other"})
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "auth"
|
assert result["step_id"] == "auth"
|
||||||
assert result["description_placeholders"] == {
|
assert result["description_placeholders"] == {
|
||||||
"authorization_url": "http://example.com"
|
"authorization_url": "http://example.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await flow.async_step_code("123ABC")
|
result = await flow.async_step_code("123ABC")
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Logi Circle ({})".format("testId")
|
assert result["title"] == "Logi Circle ({})".format("testId")
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +115,7 @@ async def test_abort_if_no_implementation_registered(hass: HomeAssistant) -> Non
|
||||||
flow.hass = hass
|
flow.hass = hass
|
||||||
|
|
||||||
result = await flow.async_step_user()
|
result = await flow.async_step_user()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "missing_configuration"
|
assert result["reason"] == "missing_configuration"
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,21 +128,21 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
config_flow.DOMAIN,
|
config_flow.DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
context={"source": config_entries.SOURCE_IMPORT},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
with pytest.raises(data_entry_flow.AbortFlow):
|
with pytest.raises(AbortFlow):
|
||||||
result = await flow.async_step_code()
|
result = await flow.async_step_code()
|
||||||
|
|
||||||
result = await flow.async_step_auth()
|
result = await flow.async_step_auth()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "external_setup"
|
assert result["reason"] == "external_setup"
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ async def test_abort_if_authorize_fails(
|
||||||
mock_logi_circle.authorize.side_effect = side_effect
|
mock_logi_circle.authorize.side_effect = side_effect
|
||||||
|
|
||||||
result = await flow.async_step_code("123ABC")
|
result = await flow.async_step_code("123ABC")
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "external_error"
|
assert result["reason"] == "external_error"
|
||||||
|
|
||||||
result = await flow.async_step_auth()
|
result = await flow.async_step_auth()
|
||||||
|
@ -172,7 +173,7 @@ async def test_not_pick_implementation_if_only_one(hass: HomeAssistant) -> None:
|
||||||
flow = init_config_flow(hass)
|
flow = init_config_flow(hass)
|
||||||
|
|
||||||
result = await flow.async_step_user()
|
result = await flow.async_step_user()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "auth"
|
assert result["step_id"] == "auth"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ async def test_manual_setup(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {CONF_HOST: IP_ADDRESS}
|
assert result["data"] == {CONF_HOST: IP_ADDRESS}
|
||||||
assert result["title"] == DEFAULT_ENTRY_TITLE
|
assert result["title"] == DEFAULT_ENTRY_TITLE
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -69,7 +69,7 @@ async def test_manual_setup_already_exists(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -134,7 +134,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None:
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"] == {CONF_HOST: IP_ADDRESS}
|
assert result2["data"] == {CONF_HOST: IP_ADDRESS}
|
||||||
assert result2["title"] == DEFAULT_ENTRY_TITLE
|
assert result2["title"] == DEFAULT_ENTRY_TITLE
|
||||||
assert mock_async_setup_entry.called
|
assert mock_async_setup_entry.called
|
||||||
|
@ -156,7 +156,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert entry.data[CONF_HOST] == "127.0.0.2"
|
assert entry.data[CONF_HOST] == "127.0.0.2"
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ async def test_discovered_zeroconf_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,5 +187,5 @@ async def test_discovered_zeroconf_unknown_exception(hass: HomeAssistant) -> Non
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
|
@ -42,7 +42,7 @@ async def test_create_entry_zeroconf(hass: HomeAssistant) -> None:
|
||||||
data=zeroconf_data,
|
data=zeroconf_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
mock_lock = Mock(spec=loqed.Lock, id="Foo")
|
mock_lock = Mock(spec=loqed.Lock, id="Foo")
|
||||||
|
@ -76,7 +76,7 @@ async def test_create_entry_zeroconf(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
found_lock = all_locks_response["data"][0]
|
found_lock = all_locks_response["data"][0]
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "LOQED Touch Smart Lock"
|
assert result2["title"] == "LOQED Touch Smart Lock"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"id": "Foo",
|
"id": "Foo",
|
||||||
|
@ -101,7 +101,7 @@ async def test_create_entry_user(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
lock_result = json.loads(load_fixture("loqed/status_ok.json"))
|
lock_result = json.loads(load_fixture("loqed/status_ok.json"))
|
||||||
|
@ -137,7 +137,7 @@ async def test_create_entry_user(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "LOQED Touch Smart Lock"
|
assert result2["title"] == "LOQED Touch Smart Lock"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"id": "Foo",
|
"id": "Foo",
|
||||||
|
@ -162,7 +162,7 @@ async def test_cannot_connect(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -175,7 +175,7 @@ async def test_cannot_connect(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ async def test_invalid_auth_when_lock_not_found(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||||
|
@ -203,7 +203,7 @@ async def test_invalid_auth_when_lock_not_found(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ async def test_cannot_connect_when_lock_not_reachable(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
all_locks_response = json.loads(load_fixture("loqed/get_all_locks.json"))
|
||||||
|
@ -236,5 +236,5 @@ async def test_cannot_connect_when_lock_not_reachable(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
|
@ -25,7 +25,7 @@ async def test_duplicate_error(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -33,7 +33,7 @@ async def test_duplicate_error(
|
||||||
user_input={CONF_SENSOR_ID: 12345},
|
user_input={CONF_SENSOR_ID: 12345},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "already_configured"
|
assert result2.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ async def test_communication_error(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
mock_luftdaten.get_data.side_effect = LuftdatenConnectionError
|
mock_luftdaten.get_data.side_effect = LuftdatenConnectionError
|
||||||
|
@ -54,7 +54,7 @@ async def test_communication_error(
|
||||||
user_input={CONF_SENSOR_ID: 12345},
|
user_input={CONF_SENSOR_ID: 12345},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "user"
|
assert result2.get("step_id") == "user"
|
||||||
assert result2.get("errors") == {CONF_SENSOR_ID: "cannot_connect"}
|
assert result2.get("errors") == {CONF_SENSOR_ID: "cannot_connect"}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ async def test_communication_error(
|
||||||
user_input={CONF_SENSOR_ID: 12345},
|
user_input={CONF_SENSOR_ID: 12345},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "12345"
|
assert result3.get("title") == "12345"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_SENSOR_ID: 12345,
|
CONF_SENSOR_ID: 12345,
|
||||||
|
@ -78,7 +78,7 @@ async def test_invalid_sensor(hass: HomeAssistant, mock_luftdaten: MagicMock) ->
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
mock_luftdaten.validate_sensor.return_value = False
|
mock_luftdaten.validate_sensor.return_value = False
|
||||||
|
@ -87,7 +87,7 @@ async def test_invalid_sensor(hass: HomeAssistant, mock_luftdaten: MagicMock) ->
|
||||||
user_input={CONF_SENSOR_ID: 11111},
|
user_input={CONF_SENSOR_ID: 11111},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "user"
|
assert result2.get("step_id") == "user"
|
||||||
assert result2.get("errors") == {CONF_SENSOR_ID: "invalid_sensor"}
|
assert result2.get("errors") == {CONF_SENSOR_ID: "invalid_sensor"}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ async def test_invalid_sensor(hass: HomeAssistant, mock_luftdaten: MagicMock) ->
|
||||||
user_input={CONF_SENSOR_ID: 12345},
|
user_input={CONF_SENSOR_ID: 12345},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "12345"
|
assert result3.get("title") == "12345"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_SENSOR_ID: 12345,
|
CONF_SENSOR_ID: 12345,
|
||||||
|
@ -114,7 +114,7 @@ async def test_step_user(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -125,7 +125,7 @@ async def test_step_user(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result2.get("title") == "12345"
|
assert result2.get("title") == "12345"
|
||||||
assert result2.get("data") == {
|
assert result2.get("data") == {
|
||||||
CONF_SENSOR_ID: 12345,
|
CONF_SENSOR_ID: 12345,
|
||||||
|
|
|
@ -45,7 +45,7 @@ async def test_form_valid_input(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -63,7 +63,7 @@ async def test_form_valid_input(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == MOCK_DATA_STEP[CONF_HOST]
|
assert result2["title"] == MOCK_DATA_STEP[CONF_HOST]
|
||||||
assert result2["data"] == MOCK_DATA_STEP
|
assert result2["data"] == MOCK_DATA_STEP
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -85,7 +85,7 @@ async def test_flow_user_init_data_error_and_recover(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -98,7 +98,7 @@ async def test_flow_user_init_data_error_and_recover(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": text_error}
|
assert result2["errors"] == {"base": text_error}
|
||||||
|
|
||||||
assert len(mock_initialize_lupusec.mock_calls) == 1
|
assert len(mock_initialize_lupusec.mock_calls) == 1
|
||||||
|
@ -120,7 +120,7 @@ async def test_flow_user_init_data_error_and_recover(
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == MOCK_DATA_STEP[CONF_HOST]
|
assert result3["title"] == MOCK_DATA_STEP[CONF_HOST]
|
||||||
assert result3["data"] == MOCK_DATA_STEP
|
assert result3["data"] == MOCK_DATA_STEP
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -141,7 +141,7 @@ async def test_flow_user_init_data_already_configured(hass: HomeAssistant) -> No
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -151,7 +151,7 @@ async def test_flow_user_init_data_already_configured(hass: HomeAssistant) -> No
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ async def test_flow_source_import(
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == mock_title
|
assert result["title"] == mock_title
|
||||||
assert result["data"] == MOCK_DATA_STEP
|
assert result["data"] == MOCK_DATA_STEP
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -214,7 +214,7 @@ async def test_flow_source_import_error_and_recover(
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == text_error
|
assert result["reason"] == text_error
|
||||||
assert len(mock_initialize_lupusec.mock_calls) == 1
|
assert len(mock_initialize_lupusec.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -236,5 +236,5 @@ async def test_flow_source_import_already_configured(hass: HomeAssistant) -> Non
|
||||||
data=MOCK_IMPORT_STEP,
|
data=MOCK_IMPORT_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -27,7 +27,7 @@ async def test_full_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -39,7 +39,7 @@ async def test_full_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
user_input=MOCK_DATA_STEP,
|
user_input=MOCK_DATA_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].title == "Lutron"
|
assert result["result"].title == "Lutron"
|
||||||
|
|
||||||
assert result["data"] == MOCK_DATA_STEP
|
assert result["data"] == MOCK_DATA_STEP
|
||||||
|
@ -63,7 +63,7 @@ async def test_flow_failure(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -75,7 +75,7 @@ async def test_flow_failure(
|
||||||
user_input=MOCK_DATA_STEP,
|
user_input=MOCK_DATA_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": text_error}
|
assert result["errors"] == {"base": text_error}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -87,7 +87,7 @@ async def test_flow_failure(
|
||||||
user_input=MOCK_DATA_STEP,
|
user_input=MOCK_DATA_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].title == "Lutron"
|
assert result["result"].title == "Lutron"
|
||||||
|
|
||||||
assert result["data"] == MOCK_DATA_STEP
|
assert result["data"] == MOCK_DATA_STEP
|
||||||
|
@ -101,7 +101,7 @@ async def test_flow_incorrect_guid(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -113,7 +113,7 @@ async def test_flow_incorrect_guid(
|
||||||
user_input=MOCK_DATA_STEP,
|
user_input=MOCK_DATA_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -125,7 +125,7 @@ async def test_flow_incorrect_guid(
|
||||||
user_input=MOCK_DATA_STEP,
|
user_input=MOCK_DATA_STEP,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_single_instance_allowed(hass: HomeAssistant) -> None:
|
async def test_flow_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||||
|
@ -137,7 +137,7 @@ async def test_flow_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ async def test_import(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == MOCK_DATA_IMPORT
|
assert result["data"] == MOCK_DATA_IMPORT
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ async def test_import_flow_failure(
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == reason
|
assert result["reason"] == reason
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ async def test_import_flow_guid_failure(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,5 +218,5 @@ async def test_import_already_configured(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_DATA_IMPORT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -9,7 +9,7 @@ from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY
|
||||||
from pylutron_caseta.smartbridge import Smartbridge
|
from pylutron_caseta.smartbridge import Smartbridge
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.lutron_caseta import DOMAIN
|
from homeassistant.components.lutron_caseta import DOMAIN
|
||||||
import homeassistant.components.lutron_caseta.config_flow as CasetaConfigFlow
|
import homeassistant.components.lutron_caseta.config_flow as CasetaConfigFlow
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.components.lutron_caseta.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import ENTRY_MOCK_DATA, MockBridge
|
from . import ENTRY_MOCK_DATA, MockBridge
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ async def test_bridge_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ async def test_bridge_cannot_connect_unknown_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,7 +151,7 @@ async def test_bridge_invalid_ssl_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
assert result["reason"] == CasetaConfigFlow.ABORT_REASON_CANNOT_CONNECT
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ async def test_duplicate_bridge_import(hass: HomeAssistant) -> None:
|
||||||
data=ENTRY_MOCK_DATA,
|
data=ENTRY_MOCK_DATA,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
ClientCredential,
|
ClientCredential,
|
||||||
async_import_client_credential,
|
async_import_client_credential,
|
||||||
)
|
)
|
||||||
from homeassistant.components.lyric.const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
from homeassistant.components.lyric.const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "missing_credentials"
|
assert result["reason"] == "missing_credentials"
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ async def test_full_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
|
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
|
||||||
"&redirect_uri=https://example.com/auth/external/callback"
|
"&redirect_uri=https://example.com/auth/external/callback"
|
||||||
|
@ -163,7 +164,7 @@ async def test_reauthentication_flow(
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
|
@ -89,7 +89,7 @@ async def test_manual_create_entry(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -101,7 +101,7 @@ async def test_manual_create_entry(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://localhost:5580/ws",
|
"url": "ws://localhost:5580/ws",
|
||||||
|
@ -139,7 +139,7 @@ async def test_manual_errors(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": error}
|
assert result["errors"] == {"base": error}
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ async def test_manual_already_configured(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -170,7 +170,7 @@ async def test_manual_already_configured(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reconfiguration_successful"
|
assert result["reason"] == "reconfiguration_successful"
|
||||||
assert entry.data["url"] == "ws://localhost:5580/ws"
|
assert entry.data["url"] == "ws://localhost:5580/ws"
|
||||||
assert entry.data["use_addon"] is False
|
assert entry.data["use_addon"] is False
|
||||||
|
@ -198,7 +198,7 @@ async def test_zeroconf_discovery(
|
||||||
properties={"SII": "3300", "SAI": "1100", "T": "0"},
|
properties={"SII": "3300", "SAI": "1100", "T": "0"},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "manual"
|
assert result["step_id"] == "manual"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ async def test_zeroconf_discovery(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://localhost:5580/ws",
|
"url": "ws://localhost:5580/ws",
|
||||||
|
@ -247,7 +247,7 @@ async def test_supervisor_discovery(
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert client_connect.call_count == 0
|
assert client_connect.call_count == 0
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -282,13 +282,13 @@ async def test_supervisor_discovery_addon_info_failed(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "addon_info_failed"
|
assert result["reason"] == "addon_info_failed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,14 +313,14 @@ async def test_clean_supervisor_discovery_on_user_create(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -328,7 +328,7 @@ async def test_clean_supervisor_discovery_on_user_create(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "manual"
|
assert result["step_id"] == "manual"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -341,7 +341,7 @@ async def test_clean_supervisor_discovery_on_user_create(
|
||||||
|
|
||||||
assert len(hass.config_entries.flow.async_progress()) == 0
|
assert len(hass.config_entries.flow.async_progress()) == 0
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://localhost:5580/ws",
|
"url": "ws://localhost:5580/ws",
|
||||||
|
@ -377,7 +377,7 @@ async def test_abort_supervisor_discovery_with_existing_entry(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ async def test_abort_supervisor_discovery_with_existing_flow(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -407,7 +407,7 @@ async def test_abort_supervisor_discovery_with_existing_flow(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ async def test_abort_supervisor_discovery_for_other_addon(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_matter_addon"
|
assert result["reason"] == "not_matter_addon"
|
||||||
|
|
||||||
|
|
||||||
|
@ -461,12 +461,12 @@ async def test_supervisor_discovery_addon_not_running(
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -475,7 +475,7 @@ async def test_supervisor_discovery_addon_not_running(
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -511,20 +511,20 @@ async def test_supervisor_discovery_addon_not_installed(
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert addon_store_info.call_count == 0
|
assert addon_store_info.call_count == 0
|
||||||
assert result["step_id"] == "hassio_confirm"
|
assert result["step_id"] == "hassio_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert addon_store_info.call_count == 1
|
assert addon_store_info.call_count == 1
|
||||||
assert result["step_id"] == "install_addon"
|
assert result["step_id"] == "install_addon"
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
|
|
||||||
assert install_addon.call_args == call(hass, "core_matter_server")
|
assert install_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -533,7 +533,7 @@ async def test_supervisor_discovery_addon_not_installed(
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -554,14 +554,14 @@ async def test_not_addon(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"use_addon": False}
|
result["flow_id"], {"use_addon": False}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "manual"
|
assert result["step_id"] == "manual"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -573,7 +573,7 @@ async def test_not_addon(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://localhost:5581/ws",
|
"url": "ws://localhost:5581/ws",
|
||||||
|
@ -597,7 +597,7 @@ async def test_addon_running(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -607,7 +607,7 @@ async def test_addon_running(
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -688,7 +688,7 @@ async def test_addon_running_failures(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -698,7 +698,7 @@ async def test_addon_running_failures(
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert get_addon_discovery_info.called is discovery_info_called
|
assert get_addon_discovery_info.called is discovery_info_called
|
||||||
assert client_connect.called is client_connect_called
|
assert client_connect.called is client_connect_called
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == abort_reason
|
assert result["reason"] == abort_reason
|
||||||
|
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ async def test_addon_running_already_configured(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -733,7 +733,7 @@ async def test_addon_running_already_configured(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reconfiguration_successful"
|
assert result["reason"] == "reconfiguration_successful"
|
||||||
assert entry.data["url"] == "ws://host1:5581/ws"
|
assert entry.data["url"] == "ws://host1:5581/ws"
|
||||||
assert entry.title == "Matter"
|
assert entry.title == "Matter"
|
||||||
|
@ -754,7 +754,7 @@ async def test_addon_installed(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -762,7 +762,7 @@ async def test_addon_installed(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -770,7 +770,7 @@ async def test_addon_installed(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -833,7 +833,7 @@ async def test_addon_installed_failures(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -841,7 +841,7 @@ async def test_addon_installed_failures(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -850,7 +850,7 @@ async def test_addon_installed_failures(
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert get_addon_discovery_info.called is discovery_info_called
|
assert get_addon_discovery_info.called is discovery_info_called
|
||||||
assert client_connect.called is client_connect_called
|
assert client_connect.called is client_connect_called
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "addon_start_failed"
|
assert result["reason"] == "addon_start_failed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ async def test_addon_installed_already_configured(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -885,7 +885,7 @@ async def test_addon_installed_already_configured(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert addon_info.call_count == 1
|
assert addon_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -893,7 +893,7 @@ async def test_addon_installed_already_configured(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reconfiguration_successful"
|
assert result["reason"] == "reconfiguration_successful"
|
||||||
assert entry.data["url"] == "ws://host1:5581/ws"
|
assert entry.data["url"] == "ws://host1:5581/ws"
|
||||||
assert entry.title == "Matter"
|
assert entry.title == "Matter"
|
||||||
|
@ -916,7 +916,7 @@ async def test_addon_not_installed(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -925,7 +925,7 @@ async def test_addon_not_installed(
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert addon_store_info.call_count == 1
|
assert addon_store_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "install_addon"
|
assert result["step_id"] == "install_addon"
|
||||||
|
|
||||||
# Make sure the flow continues when the progress task is done.
|
# Make sure the flow continues when the progress task is done.
|
||||||
|
@ -933,7 +933,7 @@ async def test_addon_not_installed(
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
|
|
||||||
assert install_addon.call_args == call(hass, "core_matter_server")
|
assert install_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -941,7 +941,7 @@ async def test_addon_not_installed(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Matter"
|
assert result["title"] == "Matter"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"url": "ws://host1:5581/ws",
|
"url": "ws://host1:5581/ws",
|
||||||
|
@ -965,14 +965,14 @@ async def test_addon_not_installed_failures(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"use_addon": True}
|
result["flow_id"], {"use_addon": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "install_addon"
|
assert result["step_id"] == "install_addon"
|
||||||
|
|
||||||
# Make sure the flow continues when the progress task is done.
|
# Make sure the flow continues when the progress task is done.
|
||||||
|
@ -981,7 +981,7 @@ async def test_addon_not_installed_failures(
|
||||||
|
|
||||||
assert install_addon.call_args == call(hass, "core_matter_server")
|
assert install_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "addon_install_failed"
|
assert result["reason"] == "addon_install_failed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1011,7 +1011,7 @@ async def test_addon_not_installed_already_configured(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "on_supervisor"
|
assert result["step_id"] == "on_supervisor"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -1020,7 +1020,7 @@ async def test_addon_not_installed_already_configured(
|
||||||
|
|
||||||
assert addon_info.call_count == 0
|
assert addon_info.call_count == 0
|
||||||
assert addon_store_info.call_count == 1
|
assert addon_store_info.call_count == 1
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "install_addon"
|
assert result["step_id"] == "install_addon"
|
||||||
|
|
||||||
# Make sure the flow continues when the progress task is done.
|
# Make sure the flow continues when the progress task is done.
|
||||||
|
@ -1028,7 +1028,7 @@ async def test_addon_not_installed_already_configured(
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
|
|
||||||
assert install_addon.call_args == call(hass, "core_matter_server")
|
assert install_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert result["type"] == FlowResultType.SHOW_PROGRESS
|
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
assert result["step_id"] == "start_addon"
|
assert result["step_id"] == "start_addon"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1037,7 +1037,7 @@ async def test_addon_not_installed_already_configured(
|
||||||
|
|
||||||
assert start_addon.call_args == call(hass, "core_matter_server")
|
assert start_addon.call_args == call(hass, "core_matter_server")
|
||||||
assert client_connect.call_count == 1
|
assert client_connect.call_count == 1
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reconfiguration_successful"
|
assert result["reason"] == "reconfiguration_successful"
|
||||||
assert entry.data["url"] == "ws://host1:5581/ws"
|
assert entry.data["url"] == "ws://host1:5581/ws"
|
||||||
assert entry.title == "Matter"
|
assert entry.title == "Matter"
|
||||||
|
|
|
@ -5,10 +5,11 @@ from unittest.mock import AsyncMock, patch
|
||||||
from meater import AuthenticationError, ServiceUnavailableError
|
from meater import AuthenticationError, ServiceUnavailableError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.meater import DOMAIN
|
from homeassistant.components.meater import DOMAIN
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ async def test_duplicate_error(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=conf
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ async def test_user_flow(hass: HomeAssistant, mock_meater) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -95,7 +96,7 @@ async def test_user_flow(hass: HomeAssistant, mock_meater) -> None:
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], conf)
|
result = await hass.config_entries.flow.async_configure(result["flow_id"], conf)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_USERNAME: "user@host.com",
|
CONF_USERNAME: "user@host.com",
|
||||||
CONF_PASSWORD: "password123",
|
CONF_PASSWORD: "password123",
|
||||||
|
@ -128,7 +129,7 @@ async def test_reauth_flow(hass: HomeAssistant, mock_meater) -> None:
|
||||||
data=data,
|
data=data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ async def test_reauth_flow(hass: HomeAssistant, mock_meater) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
|
|
||||||
config_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
config_entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
|
|
|
@ -31,7 +31,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
|
||||||
data=MEDCOM_SERVICE_INFO,
|
data=MEDCOM_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
assert result["description_placeholders"] == {"name": "InspectorBLE-D9A0"}
|
assert result["description_placeholders"] == {"name": "InspectorBLE-D9A0"}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={"not": "empty"}
|
result["flow_id"], user_input={"not": "empty"}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "InspectorBLE-D9A0"
|
assert result["title"] == "InspectorBLE-D9A0"
|
||||||
assert result["result"].unique_id == "a0:d9:5a:57:0b:00"
|
assert result["result"].unique_id == "a0:d9:5a:57:0b:00"
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ async def test_bluetooth_discovery_already_setup(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MEDCOM_DEVICE_INFO,
|
data=MEDCOM_DEVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -113,7 +113,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "InspectorBLE-D9A0"
|
assert result["title"] == "InspectorBLE-D9A0"
|
||||||
assert result["result"].unique_id == "a0:d9:5a:57:0b:00"
|
assert result["result"].unique_id == "a0:d9:5a:57:0b:00"
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ async def test_user_setup_no_device(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ async def test_user_setup_existing_and_unknown_device(hass: HomeAssistant) -> No
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -154,7 +154,7 @@ async def test_user_setup_existing_and_unknown_device(hass: HomeAssistant) -> No
|
||||||
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ async def test_user_setup_unknown_device(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ async def test_user_setup_unknown_error(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -193,7 +193,7 @@ async def test_user_setup_unknown_error(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ async def test_user_setup_unable_to_connect(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
assert result["data_schema"] is not None
|
assert result["data_schema"] is not None
|
||||||
|
@ -224,5 +224,5 @@ async def test_user_setup_unable_to_connect(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
result["flow_id"], user_input={CONF_ADDRESS: "a0:d9:5a:57:0b:00"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
|
@ -174,7 +174,7 @@ async def test_token_reauthentication(
|
||||||
},
|
},
|
||||||
data=mock_entry.data,
|
data=mock_entry.data,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -187,7 +187,7 @@ async def test_token_reauthentication(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ async def test_form_errors_reauthentication(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"]["base"] == reason
|
assert result["errors"]["base"] == reason
|
||||||
|
|
||||||
mock_login.side_effect = None
|
mock_login.side_effect = None
|
||||||
|
@ -245,7 +245,7 @@ async def test_form_errors_reauthentication(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ async def test_client_errors_reauthentication(
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["errors"]["base"] == reason
|
assert result["errors"]["base"] == reason
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
mock_login.side_effect = None
|
mock_login.side_effect = None
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -303,5 +303,5 @@ async def test_client_errors_reauthentication(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
|
@ -29,7 +29,7 @@ async def test_user_step_no_devices(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
mock_setup_entry.assert_not_called()
|
mock_setup_entry.assert_not_called()
|
||||||
|
@ -46,7 +46,7 @@ async def test_user_step_discovered_devices(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "pick_device"
|
assert result["step_id"] == "pick_device"
|
||||||
|
|
||||||
with pytest.raises(vol.Invalid):
|
with pytest.raises(vol.Invalid):
|
||||||
|
@ -58,7 +58,7 @@ async def test_user_step_discovered_devices(
|
||||||
result["flow_id"], user_input={CONF_ADDRESS: FAKE_ADDRESS_1}
|
result["flow_id"], user_input={CONF_ADDRESS: FAKE_ADDRESS_1}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"] == {CONF_ADDRESS: FAKE_ADDRESS_1}
|
assert result2["data"] == {CONF_ADDRESS: FAKE_ADDRESS_1}
|
||||||
|
|
||||||
mock_setup_entry.assert_called_once()
|
mock_setup_entry.assert_called_once()
|
||||||
|
@ -94,7 +94,7 @@ async def test_user_step_with_existing_device(
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with pytest.raises(vol.Invalid):
|
with pytest.raises(vol.Invalid):
|
||||||
await hass.config_entries.flow.async_configure(
|
await hass.config_entries.flow.async_configure(
|
||||||
|
@ -115,7 +115,7 @@ async def test_bluetooth_discovered(
|
||||||
data=FAKE_SERVICE_INFO_1,
|
data=FAKE_SERVICE_INFO_1,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
assert result["description_placeholders"] == {"name": FAKE_ADDRESS_1}
|
assert result["description_placeholders"] == {"name": FAKE_ADDRESS_1}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ async def test_bluetooth_confirm(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == FAKE_ADDRESS_1
|
assert result2["title"] == FAKE_ADDRESS_1
|
||||||
assert result2["data"] == {CONF_ADDRESS: FAKE_ADDRESS_1}
|
assert result2["data"] == {CONF_ADDRESS: FAKE_ADDRESS_1}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.met_eireann.const import DOMAIN, HOME_LOCATION_NAME
|
from homeassistant.components.met_eireann.const import DOMAIN, HOME_LOCATION_NAME
|
||||||
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE
|
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="met_eireann_setup", autouse=True)
|
@pytest.fixture(name="met_eireann_setup", autouse=True)
|
||||||
|
@ -66,7 +67,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == test_data.get("name")
|
assert result["title"] == test_data.get("name")
|
||||||
assert result["data"] == test_data
|
assert result["data"] == test_data
|
||||||
|
|
||||||
|
@ -87,11 +88,11 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
result1 = await hass.config_entries.flow.async_init(
|
result1 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
assert result1["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result1["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
# Create the second entry and assert that it is aborted
|
# Create the second entry and assert that it is aborted
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
|
||||||
)
|
)
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
|
@ -5,11 +5,11 @@ from unittest.mock import patch
|
||||||
from meteofrance_api.model import Place
|
from meteofrance_api.model import Place
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.meteo_france.const import CONF_CITY, DOMAIN
|
from homeassistant.components.meteo_france.const import CONF_CITY, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ async def test_user(hass: HomeAssistant, client_single) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# test with all provided with search returning only 1 place
|
# test with all provided with search returning only 1 place
|
||||||
|
@ -123,7 +123,7 @@ async def test_user(hass: HomeAssistant, client_single) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_CITY: CITY_1_POSTAL},
|
data={CONF_CITY: CITY_1_POSTAL},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == f"{CITY_1_LAT}, {CITY_1_LON}"
|
assert result["result"].unique_id == f"{CITY_1_LAT}, {CITY_1_LON}"
|
||||||
assert result["title"] == f"{CITY_1}"
|
assert result["title"] == f"{CITY_1}"
|
||||||
assert result["data"][CONF_LATITUDE] == str(CITY_1_LAT)
|
assert result["data"][CONF_LATITUDE] == str(CITY_1_LAT)
|
||||||
|
@ -139,14 +139,14 @@ async def test_user_list(hass: HomeAssistant, client_multiple) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_CITY: CITY_2_NAME},
|
data={CONF_CITY: CITY_2_NAME},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "cities"
|
assert result["step_id"] == "cities"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_CITY: f"{CITY_3};{CITY_3_LAT};{CITY_3_LON}"},
|
user_input={CONF_CITY: f"{CITY_3};{CITY_3_LAT};{CITY_3_LON}"},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == f"{CITY_3_LAT}, {CITY_3_LON}"
|
assert result["result"].unique_id == f"{CITY_3_LAT}, {CITY_3_LON}"
|
||||||
assert result["title"] == f"{CITY_3}"
|
assert result["title"] == f"{CITY_3}"
|
||||||
assert result["data"][CONF_LATITUDE] == str(CITY_3_LAT)
|
assert result["data"][CONF_LATITUDE] == str(CITY_3_LAT)
|
||||||
|
@ -161,7 +161,7 @@ async def test_search_failed(hass: HomeAssistant, client_empty) -> None:
|
||||||
data={CONF_CITY: CITY_1_POSTAL},
|
data={CONF_CITY: CITY_1_POSTAL},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {CONF_CITY: "empty"}
|
assert result["errors"] == {CONF_CITY: "empty"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,5 +179,5 @@ async def test_abort_if_already_setup(hass: HomeAssistant, client_single) -> Non
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_CITY: CITY_1_POSTAL},
|
data={CONF_CITY: CITY_1_POSTAL},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -5,10 +5,10 @@ from unittest.mock import patch
|
||||||
from meteoclimatic.exceptions import MeteoclimaticError, StationNotFound
|
from meteoclimatic.exceptions import MeteoclimaticError, StationNotFound
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.meteoclimatic.const import CONF_STATION_CODE, DOMAIN
|
from homeassistant.components.meteoclimatic.const import CONF_STATION_CODE, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
TEST_STATION_CODE = "ESCAT4300000043206B"
|
TEST_STATION_CODE = "ESCAT4300000043206B"
|
||||||
TEST_STATION_NAME = "Reus (Tarragona)"
|
TEST_STATION_NAME = "Reus (Tarragona)"
|
||||||
|
@ -44,7 +44,7 @@ async def test_user(hass: HomeAssistant, client) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# test with all provided
|
# test with all provided
|
||||||
|
@ -53,7 +53,7 @@ async def test_user(hass: HomeAssistant, client) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == TEST_STATION_CODE
|
assert result["result"].unique_id == TEST_STATION_CODE
|
||||||
assert result["title"] == TEST_STATION_NAME
|
assert result["title"] == TEST_STATION_NAME
|
||||||
assert result["data"][CONF_STATION_CODE] == TEST_STATION_CODE
|
assert result["data"][CONF_STATION_CODE] == TEST_STATION_CODE
|
||||||
|
@ -70,7 +70,7 @@ async def test_not_found(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "not_found"
|
assert result["errors"]["base"] == "not_found"
|
||||||
|
|
||||||
|
@ -86,5 +86,5 @@ async def test_unknown_error(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
data={CONF_STATION_CODE: TEST_STATION_CODE},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
|
@ -37,7 +37,7 @@ async def test_full_flow(
|
||||||
"redirect_uri": "https://example.com/auth/external/callback",
|
"redirect_uri": "https://example.com/auth/external/callback",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{MICROBEES_AUTH_URI}?"
|
f"{MICROBEES_AUTH_URI}?"
|
||||||
f"response_type=code&client_id={CLIENT_ID}&"
|
f"response_type=code&client_id={CLIENT_ID}&"
|
||||||
|
@ -71,7 +71,7 @@ async def test_full_flow(
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
assert len(mock_setup.mock_calls) == 1
|
assert len(mock_setup.mock_calls) == 1
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "test@microbees.com"
|
assert result["title"] == "test@microbees.com"
|
||||||
assert "result" in result
|
assert "result" in result
|
||||||
assert result["result"].unique_id == 54321
|
assert result["result"].unique_id == 54321
|
||||||
|
@ -101,7 +101,7 @@ async def test_config_non_unique_profile(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{MICROBEES_AUTH_URI}?"
|
f"{MICROBEES_AUTH_URI}?"
|
||||||
f"response_type=code&client_id={CLIENT_ID}&"
|
f"response_type=code&client_id={CLIENT_ID}&"
|
||||||
|
@ -129,7 +129,7 @@ async def test_config_non_unique_profile(
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ async def test_config_reauth_profile(
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result
|
assert result
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ async def test_config_reauth_wrong_account(
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result
|
assert result
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "wrong_account"
|
assert result["reason"] == "wrong_account"
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ async def test_config_flow_with_invalid_credentials(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{MICROBEES_AUTH_URI}?"
|
f"{MICROBEES_AUTH_URI}?"
|
||||||
f"response_type=code&client_id={CLIENT_ID}&"
|
f"response_type=code&client_id={CLIENT_ID}&"
|
||||||
|
@ -299,7 +299,7 @@ async def test_config_flow_with_invalid_credentials(
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result
|
assert result
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "oauth_error"
|
assert result["reason"] == "oauth_error"
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ async def test_unexpected_exceptions(
|
||||||
"redirect_uri": "https://example.com/auth/external/callback",
|
"redirect_uri": "https://example.com/auth/external/callback",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||||
assert result["url"] == (
|
assert result["url"] == (
|
||||||
f"{MICROBEES_AUTH_URI}?"
|
f"{MICROBEES_AUTH_URI}?"
|
||||||
f"response_type=code&client_id={CLIENT_ID}&"
|
f"response_type=code&client_id={CLIENT_ID}&"
|
||||||
|
@ -362,5 +362,5 @@ async def test_unexpected_exceptions(
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result
|
assert result
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == error
|
assert result["reason"] == error
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
import librouteros
|
import librouteros
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.mikrotik.const import (
|
from homeassistant.components.mikrotik.const import (
|
||||||
CONF_ARP_PING,
|
CONF_ARP_PING,
|
||||||
CONF_DETECTION_TIME,
|
CONF_DETECTION_TIME,
|
||||||
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -75,14 +76,14 @@ async def test_flow_works(hass: HomeAssistant, api) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Mikrotik (0.0.0.0)"
|
assert result["title"] == "Mikrotik (0.0.0.0)"
|
||||||
assert result["data"][CONF_HOST] == "0.0.0.0"
|
assert result["data"][CONF_HOST] == "0.0.0.0"
|
||||||
assert result["data"][CONF_USERNAME] == "username"
|
assert result["data"][CONF_USERNAME] == "username"
|
||||||
|
@ -100,7 +101,7 @@ async def test_options(hass: HomeAssistant, api) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "device_tracker"
|
assert result["step_id"] == "device_tracker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -112,7 +113,7 @@ async def test_options(hass: HomeAssistant, api) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_DETECTION_TIME: 30,
|
CONF_DETECTION_TIME: 30,
|
||||||
CONF_ARP_PING: True,
|
CONF_ARP_PING: True,
|
||||||
|
@ -145,7 +146,7 @@ async def test_connection_error(hass: HomeAssistant, conn_error) -> None:
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ async def test_wrong_credentials(hass: HomeAssistant, auth_error) -> None:
|
||||||
result["flow_id"], user_input=DEMO_USER_INPUT
|
result["flow_id"], user_input=DEMO_USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {
|
assert result["errors"] == {
|
||||||
CONF_USERNAME: "invalid_auth",
|
CONF_USERNAME: "invalid_auth",
|
||||||
CONF_PASSWORD: "invalid_auth",
|
CONF_PASSWORD: "invalid_auth",
|
||||||
|
|
|
@ -17,7 +17,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -35,7 +35,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: CLOUD,
|
CONNECTION_TYPE: CLOUD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=True):
|
with patch("mill.Mill.connect", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -74,7 +74,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -83,7 +83,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: CLOUD,
|
CONNECTION_TYPE: CLOUD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=True):
|
with patch("mill.Mill.connect", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -101,7 +101,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -110,7 +110,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: CLOUD,
|
CONNECTION_TYPE: CLOUD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("mill.Mill.connect", return_value=False):
|
with patch("mill.Mill.connect", return_value=False):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -121,7 +121,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -139,7 +139,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: LOCAL,
|
CONNECTION_TYPE: LOCAL,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
test_data = {
|
test_data = {
|
||||||
CONF_IP_ADDRESS: "192.168.1.59",
|
CONF_IP_ADDRESS: "192.168.1.59",
|
||||||
|
@ -182,7 +182,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -191,7 +191,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: LOCAL,
|
CONNECTION_TYPE: LOCAL,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
test_data = {
|
test_data = {
|
||||||
CONF_IP_ADDRESS: "192.168.1.59",
|
CONF_IP_ADDRESS: "192.168.1.59",
|
||||||
|
@ -221,7 +221,7 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -230,7 +230,7 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
|
||||||
CONNECTION_TYPE: LOCAL,
|
CONNECTION_TYPE: LOCAL,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
test_data = {
|
test_data = {
|
||||||
CONF_IP_ADDRESS: "192.168.1.59",
|
CONF_IP_ADDRESS: "192.168.1.59",
|
||||||
|
@ -245,5 +245,5 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
|
||||||
test_data,
|
test_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
|
@ -20,7 +20,7 @@ async def test_config_flow(hass: HomeAssistant, platform: str) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -33,7 +33,7 @@ async def test_config_flow(hass: HomeAssistant, platform: str) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "My min_max"
|
assert result["title"] == "My min_max"
|
||||||
assert result["data"] == {}
|
assert result["data"] == {}
|
||||||
assert result["options"] == {
|
assert result["options"] == {
|
||||||
|
@ -93,7 +93,7 @@ async def test_options(hass: HomeAssistant, platform: str) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
schema = result["data_schema"].schema
|
schema = result["data_schema"].schema
|
||||||
assert get_suggested(schema, "entity_ids") == input_sensors1
|
assert get_suggested(schema, "entity_ids") == input_sensors1
|
||||||
|
@ -108,7 +108,7 @@ async def test_options(hass: HomeAssistant, platform: str) -> None:
|
||||||
"type": "mean",
|
"type": "mean",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"entity_ids": input_sensors2,
|
"entity_ids": input_sensors2,
|
||||||
"name": "My min_max",
|
"name": "My min_max",
|
||||||
|
|
|
@ -31,7 +31,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ async def test_address_validation_failure(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ async def test_java_connection_failure(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ async def test_bedrock_connection_failure(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ async def test_java_connection(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == USER_INPUT[CONF_ADDRESS]
|
assert result["title"] == USER_INPUT[CONF_ADDRESS]
|
||||||
assert result["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
assert result["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
||||||
assert result["data"][CONF_ADDRESS] == TEST_ADDRESS
|
assert result["data"][CONF_ADDRESS] == TEST_ADDRESS
|
||||||
|
@ -142,7 +142,7 @@ async def test_bedrock_connection(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == USER_INPUT[CONF_ADDRESS]
|
assert result["title"] == USER_INPUT[CONF_ADDRESS]
|
||||||
assert result["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
assert result["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
||||||
assert result["data"][CONF_ADDRESS] == TEST_ADDRESS
|
assert result["data"][CONF_ADDRESS] == TEST_ADDRESS
|
||||||
|
@ -164,7 +164,7 @@ async def test_recovery(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
DOMAIN, context={"source": SOURCE_USER}, data=USER_INPUT
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -180,7 +180,7 @@ async def test_recovery(hass: HomeAssistant) -> None:
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
flow_id=result["flow_id"], user_input=USER_INPUT
|
flow_id=result["flow_id"], user_input=USER_INPUT
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == USER_INPUT[CONF_ADDRESS]
|
assert result2["title"] == USER_INPUT[CONF_ADDRESS]
|
||||||
assert result2["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
assert result2["data"][CONF_NAME] == USER_INPUT[CONF_NAME]
|
||||||
assert result2["data"][CONF_ADDRESS] == TEST_ADDRESS
|
assert result2["data"][CONF_ADDRESS] == TEST_ADDRESS
|
||||||
|
|
|
@ -35,7 +35,7 @@ async def test_full_user_flow(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -50,7 +50,7 @@ async def test_full_user_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result2.get("title") == "Spy cam"
|
assert result2.get("title") == "Spy cam"
|
||||||
assert result2.get("data") == {}
|
assert result2.get("data") == {}
|
||||||
assert result2.get("options") == {
|
assert result2.get("options") == {
|
||||||
|
@ -80,7 +80,7 @@ async def test_full_flow_with_authentication_error(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
mock_mjpeg_requests.get(
|
mock_mjpeg_requests.get(
|
||||||
|
@ -96,7 +96,7 @@ async def test_full_flow_with_authentication_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "user"
|
assert result2.get("step_id") == "user"
|
||||||
assert result2.get("errors") == {"username": "invalid_auth"}
|
assert result2.get("errors") == {"username": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ async def test_full_flow_with_authentication_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Sky cam"
|
assert result3.get("title") == "Sky cam"
|
||||||
assert result3.get("data") == {}
|
assert result3.get("data") == {}
|
||||||
assert result3.get("options") == {
|
assert result3.get("options") == {
|
||||||
|
@ -140,7 +140,7 @@ async def test_connection_error(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
# Test connectione error on MJPEG url
|
# Test connectione error on MJPEG url
|
||||||
|
@ -156,7 +156,7 @@ async def test_connection_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "user"
|
assert result2.get("step_id") == "user"
|
||||||
assert result2.get("errors") == {"mjpeg_url": "cannot_connect"}
|
assert result2.get("errors") == {"mjpeg_url": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ async def test_connection_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.FORM
|
assert result3.get("type") is FlowResultType.FORM
|
||||||
assert result3.get("step_id") == "user"
|
assert result3.get("step_id") == "user"
|
||||||
assert result3.get("errors") == {"still_image_url": "cannot_connect"}
|
assert result3.get("errors") == {"still_image_url": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ async def test_connection_error(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result4.get("type") == FlowResultType.CREATE_ENTRY
|
assert result4.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result4.get("title") == "My cam"
|
assert result4.get("title") == "My cam"
|
||||||
assert result4.get("data") == {}
|
assert result4.get("data") == {}
|
||||||
assert result4.get("options") == {
|
assert result4.get("options") == {
|
||||||
|
@ -236,7 +236,7 @@ async def test_already_configured(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "already_configured"
|
assert result2.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ async def test_options_flow(
|
||||||
"""Test options config flow."""
|
"""Test options config flow."""
|
||||||
result = await hass.config_entries.options.async_init(init_integration.entry_id)
|
result = await hass.config_entries.options.async_init(init_integration.entry_id)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "init"
|
assert result.get("step_id") == "init"
|
||||||
|
|
||||||
# Register a second camera
|
# Register a second camera
|
||||||
|
@ -276,7 +276,7 @@ async def test_options_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "init"
|
assert result2.get("step_id") == "init"
|
||||||
assert result2.get("errors") == {"mjpeg_url": "already_configured"}
|
assert result2.get("errors") == {"mjpeg_url": "already_configured"}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ async def test_options_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3.get("type") == FlowResultType.FORM
|
assert result3.get("type") is FlowResultType.FORM
|
||||||
assert result3.get("step_id") == "init"
|
assert result3.get("step_id") == "init"
|
||||||
assert result3.get("errors") == {"mjpeg_url": "cannot_connect"}
|
assert result3.get("errors") == {"mjpeg_url": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ async def test_options_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result4.get("type") == FlowResultType.FORM
|
assert result4.get("type") is FlowResultType.FORM
|
||||||
assert result4.get("step_id") == "init"
|
assert result4.get("step_id") == "init"
|
||||||
assert result4.get("errors") == {"still_image_url": "cannot_connect"}
|
assert result4.get("errors") == {"still_image_url": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ async def test_options_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result5.get("type") == FlowResultType.FORM
|
assert result5.get("type") is FlowResultType.FORM
|
||||||
assert result5.get("step_id") == "init"
|
assert result5.get("step_id") == "init"
|
||||||
assert result5.get("errors") == {"username": "invalid_auth"}
|
assert result5.get("errors") == {"username": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ async def test_options_flow(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result6.get("type") == FlowResultType.CREATE_ENTRY
|
assert result6.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result6.get("data") == {
|
assert result6.get("data") == {
|
||||||
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
|
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
|
||||||
CONF_MJPEG_URL: "https://example.com/mjpeg",
|
CONF_MJPEG_URL: "https://example.com/mjpeg",
|
||||||
|
|
|
@ -19,13 +19,13 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MOAT_S2_SERVICE_INFO,
|
data=MOAT_S2_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Moat S2 EEFF"
|
assert result2["title"] == "Moat S2 EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
@ -38,7 +38,7 @@ async def test_async_step_bluetooth_not_moat(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=NOT_MOAT_SERVICE_INFO,
|
data=NOT_MOAT_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Moat S2 EEFF"
|
assert result2["title"] == "Moat S2 EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
@ -85,7 +85,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
@ -99,7 +99,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ async def test_async_step_user_with_found_devices_already_setup(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MOAT_S2_SERVICE_INFO,
|
data=MOAT_S2_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MOAT_S2_SERVICE_INFO,
|
data=MOAT_S2_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -157,7 +157,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MOAT_S2_SERVICE_INFO,
|
data=MOAT_S2_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=MOAT_S2_SERVICE_INFO,
|
data=MOAT_S2_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -181,14 +181,14 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.moat.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Moat S2 EEFF"
|
assert result2["title"] == "Moat S2 EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
|
|
@ -4,12 +4,12 @@ from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import phone_modem
|
import phone_modem
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components import usb
|
from homeassistant.components import usb
|
||||||
from homeassistant.components.modem_callerid.const import DOMAIN
|
from homeassistant.components.modem_callerid.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USB, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USB, SOURCE_USER
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_SOURCE
|
from homeassistant.const import CONF_DEVICE, CONF_SOURCE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import com_port, patch_config_flow_modem
|
from . import com_port, patch_config_flow_modem
|
||||||
|
|
||||||
|
@ -38,14 +38,14 @@ async def test_flow_usb(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USB},
|
context={CONF_SOURCE: SOURCE_USB},
|
||||||
data=DISCOVERY_INFO,
|
data=DISCOVERY_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "usb_confirm"
|
assert result["step_id"] == "usb_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_DEVICE: phone_modem.DEFAULT_PORT},
|
user_input={CONF_DEVICE: phone_modem.DEFAULT_PORT},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {CONF_DEVICE: com_port().device}
|
assert result["data"] == {CONF_DEVICE: com_port().device}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ async def test_flow_usb_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
|
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USER},
|
context={CONF_SOURCE: SOURCE_USER},
|
||||||
data={CONF_DEVICE: port_select},
|
data={CONF_DEVICE: port_select},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {CONF_DEVICE: port.device}
|
assert result["data"] == {CONF_DEVICE: port.device}
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -87,7 +87,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USER},
|
context={CONF_SOURCE: SOURCE_USER},
|
||||||
data={CONF_DEVICE: port_select},
|
data={CONF_DEVICE: port_select},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ async def test_flow_user_error(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data={CONF_DEVICE: port_select}
|
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data={CONF_DEVICE: port_select}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ async def test_flow_user_error(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_DEVICE: port_select},
|
user_input={CONF_DEVICE: port_select},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {CONF_DEVICE: port.device}
|
assert result["data"] == {CONF_DEVICE: port.device}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ async def test_flow_user_no_port_list(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USER},
|
context={CONF_SOURCE: SOURCE_USER},
|
||||||
data={CONF_DEVICE: phone_modem.DEFAULT_PORT},
|
data={CONF_DEVICE: phone_modem.DEFAULT_PORT},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ async def test_abort_user_with_existing_flow(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_USB},
|
context={CONF_SOURCE: SOURCE_USB},
|
||||||
data=DISCOVERY_INFO,
|
data=DISCOVERY_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "usb_confirm"
|
assert result["step_id"] == "usb_confirm"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
|
@ -151,5 +151,5 @@ async def test_abort_user_with_existing_flow(hass: HomeAssistant) -> None:
|
||||||
data={},
|
data={},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_in_progress"
|
assert result2["reason"] == "already_in_progress"
|
||||||
|
|
|
@ -35,7 +35,7 @@ async def test_full_user_flow_implementation(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.modern_forms.async_setup_entry",
|
"homeassistant.components.modern_forms.async_setup_entry",
|
||||||
|
@ -47,7 +47,7 @@ async def test_full_user_flow_implementation(
|
||||||
|
|
||||||
assert result2.get("title") == "ModernFormsFan"
|
assert result2.get("title") == "ModernFormsFan"
|
||||||
assert "data" in result2
|
assert "data" in result2
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"][CONF_HOST] == "192.168.1.123"
|
assert result2["data"][CONF_HOST] == "192.168.1.123"
|
||||||
assert result2["data"][CONF_MAC] == "AA:BB:CC:DD:EE:FF"
|
assert result2["data"][CONF_MAC] == "AA:BB:CC:DD:EE:FF"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -82,7 +82,7 @@ async def test_full_zeroconf_flow_implementation(
|
||||||
|
|
||||||
assert result.get("description_placeholders") == {CONF_NAME: "example"}
|
assert result.get("description_placeholders") == {CONF_NAME: "example"}
|
||||||
assert result.get("step_id") == "zeroconf_confirm"
|
assert result.get("step_id") == "zeroconf_confirm"
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
|
|
||||||
flow = flows[0]
|
flow = flows[0]
|
||||||
assert "context" in flow
|
assert "context" in flow
|
||||||
|
@ -94,7 +94,7 @@ async def test_full_zeroconf_flow_implementation(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("title") == "example"
|
assert result2.get("title") == "example"
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
assert "data" in result2
|
assert "data" in result2
|
||||||
assert result2["data"][CONF_HOST] == "192.168.1.123"
|
assert result2["data"][CONF_HOST] == "192.168.1.123"
|
||||||
|
@ -117,7 +117,7 @@ async def test_connection_error(
|
||||||
data={CONF_HOST: "example.com"},
|
data={CONF_HOST: "example.com"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
assert result.get("errors") == {"base": "cannot_connect"}
|
assert result.get("errors") == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ async def test_zeroconf_connection_error(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "cannot_connect"
|
assert result.get("reason") == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ async def test_zeroconf_confirm_connection_error(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "cannot_connect"
|
assert result.get("reason") == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ async def test_user_device_exists_abort(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -248,5 +248,5 @@ async def test_zeroconf_with_mac_device_exists_abort(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
|
@ -29,7 +29,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -45,7 +45,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == MOCK_BASE_NAME
|
assert result2["title"] == MOCK_BASE_NAME
|
||||||
assert result2["data"] == {"host": MOCK_BASE_HOST}
|
assert result2["data"] == {"host": MOCK_BASE_HOST}
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -68,7 +68,7 @@ async def test_form_duplicate_error(hass: HomeAssistant) -> None:
|
||||||
data={"host": MOCK_BASE_HOST},
|
data={"host": MOCK_BASE_HOST},
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ async def test_form_cannot_connect_error(hass: HomeAssistant) -> None:
|
||||||
user_input={"host": MOCK_BASE_HOST},
|
user_input={"host": MOCK_BASE_HOST},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,5 +98,5 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
|
||||||
user_input={"host": MOCK_BASE_HOST},
|
user_input={"host": MOCK_BASE_HOST},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.monoprice.const import (
|
from homeassistant.components.monoprice.const import (
|
||||||
CONF_SOURCE_1,
|
CONF_SOURCE_1,
|
||||||
CONF_SOURCE_4,
|
CONF_SOURCE_4,
|
||||||
|
@ -14,6 +14,7 @@ from homeassistant.components.monoprice.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_PORT
|
from homeassistant.const import CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -120,5 +121,5 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_SOURCE_1: "one", CONF_SOURCE_4: "", CONF_SOURCE_5: "five"},
|
user_input={CONF_SOURCE_1: "one", CONF_SOURCE_4: "", CONF_SOURCE_5: "five"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options[CONF_SOURCES] == {"1": "one", "5": "five"}
|
assert config_entry.options[CONF_SOURCES] == {"1": "one", "5": "five"}
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def test_full_user_flow(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -27,7 +27,7 @@ async def test_full_user_flow(
|
||||||
user_input={},
|
user_input={},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result2.get("title") == "Moon"
|
assert result2.get("title") == "Moon"
|
||||||
assert result2.get("data") == {}
|
assert result2.get("data") == {}
|
||||||
|
|
||||||
|
@ -43,5 +43,5 @@ async def test_single_instance_allowed(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "single_instance_allowed"
|
assert result.get("reason") == "single_instance_allowed"
|
||||||
|
|
|
@ -19,13 +19,13 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=PRO_SERVICE_INFO,
|
data=PRO_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Pro Plus EEFF"
|
assert result2["title"] == "Pro Plus EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
@ -38,7 +38,7 @@ async def test_async_step_bluetooth_not_mopeka(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=NOT_MOPEKA_SERVICE_INFO,
|
data=NOT_MOPEKA_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_supported"
|
assert result["reason"] == "not_supported"
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Pro Plus EEFF"
|
assert result2["title"] == "Pro Plus EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
@ -85,7 +85,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
@ -99,7 +99,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ async def test_async_step_user_with_found_devices_already_setup(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=PRO_SERVICE_INFO,
|
data=PRO_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=PRO_SERVICE_INFO,
|
data=PRO_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -157,7 +157,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=PRO_SERVICE_INFO,
|
data=PRO_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_in_progress"
|
assert result["reason"] == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=PRO_SERVICE_INFO,
|
data=PRO_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "bluetooth_confirm"
|
assert result["step_id"] == "bluetooth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -181,14 +181,14 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.mopeka.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
user_input={"address": "aa:bb:cc:dd:ee:ff"},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Pro Plus EEFF"
|
assert result2["title"] == "Pro Plus EEFF"
|
||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
|
||||||
|
|
|
@ -5,12 +5,13 @@ from unittest.mock import Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.components.motion_blinds import const
|
from homeassistant.components.motion_blinds import const
|
||||||
from homeassistant.components.motion_blinds.config_flow import DEFAULT_GATEWAY_NAME
|
from homeassistant.components.motion_blinds.config_flow import DEFAULT_GATEWAY_NAME
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST
|
from homeassistant.const import CONF_API_KEY, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -435,7 +436,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -443,7 +444,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
user_input={const.CONF_WAIT_FOR_PUSH: False},
|
user_input={const.CONF_WAIT_FOR_PUSH: False},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
const.CONF_WAIT_FOR_PUSH: False,
|
const.CONF_WAIT_FOR_PUSH: False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,12 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from motionblindsble.const import MotionBlindType
|
from motionblindsble.const import MotionBlindType
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak
|
from homeassistant.components.bluetooth.models import BluetoothServiceInfoBleak
|
||||||
from homeassistant.components.motionblinds_ble import const
|
from homeassistant.components.motionblinds_ble import const
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .conftest import TEST_ADDRESS, TEST_MAC, TEST_NAME
|
from .conftest import TEST_ADDRESS, TEST_MAC, TEST_NAME
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ async def test_config_flow_manual_success(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -56,14 +57,14 @@ async def test_config_flow_manual_success(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_ADDRESS: TEST_ADDRESS,
|
CONF_ADDRESS: TEST_ADDRESS,
|
||||||
|
@ -83,7 +84,7 @@ async def test_config_flow_manual_error_invalid_mac(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ async def test_config_flow_manual_error_invalid_mac(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: "AABBCC"}, # A MAC code should be 4 characters
|
{const.CONF_MAC_CODE: "AABBCC"}, # A MAC code should be 4 characters
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": const.ERROR_INVALID_MAC_CODE}
|
assert result["errors"] == {"base": const.ERROR_INVALID_MAC_CODE}
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ async def test_config_flow_manual_error_invalid_mac(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
# Finish flow
|
# Finish flow
|
||||||
|
@ -109,7 +110,7 @@ async def test_config_flow_manual_error_invalid_mac(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_ADDRESS: TEST_ADDRESS,
|
CONF_ADDRESS: TEST_ADDRESS,
|
||||||
|
@ -133,14 +134,14 @@ async def test_config_flow_manual_error_no_bluetooth_adapter(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == const.ERROR_NO_BLUETOOTH_ADAPTER
|
assert result["reason"] == const.ERROR_NO_BLUETOOTH_ADAPTER
|
||||||
|
|
||||||
# Try discovery with zero Bluetooth adapters
|
# Try discovery with zero Bluetooth adapters
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ async def test_config_flow_manual_error_no_bluetooth_adapter(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == const.ERROR_NO_BLUETOOTH_ADAPTER
|
assert result["reason"] == const.ERROR_NO_BLUETOOTH_ADAPTER
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@ async def test_config_flow_manual_error_could_not_find_motor(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ async def test_config_flow_manual_error_could_not_find_motor(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": const.ERROR_COULD_NOT_FIND_MOTOR}
|
assert result["errors"] == {"base": const.ERROR_COULD_NOT_FIND_MOTOR}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ async def test_config_flow_manual_error_could_not_find_motor(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
# Finish flow
|
# Finish flow
|
||||||
|
@ -193,7 +194,7 @@ async def test_config_flow_manual_error_could_not_find_motor(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_ADDRESS: TEST_ADDRESS,
|
CONF_ADDRESS: TEST_ADDRESS,
|
||||||
|
@ -213,7 +214,7 @@ async def test_config_flow_manual_error_no_devices_found(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -223,7 +224,7 @@ async def test_config_flow_manual_error_no_devices_found(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{const.CONF_MAC_CODE: TEST_MAC},
|
{const.CONF_MAC_CODE: TEST_MAC},
|
||||||
)
|
)
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == const.ERROR_NO_DEVICES_FOUND
|
assert result["reason"] == const.ERROR_NO_DEVICES_FOUND
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,7 +238,7 @@ async def test_config_flow_bluetooth_success(
|
||||||
data=BLIND_SERVICE_INFO,
|
data=BLIND_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -245,7 +246,7 @@ async def test_config_flow_bluetooth_success(
|
||||||
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
{const.CONF_BLIND_TYPE: MotionBlindType.ROLLER.name.lower()},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
assert result["title"] == f"Motionblind {TEST_MAC.upper()}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_ADDRESS: TEST_ADDRESS,
|
CONF_ADDRESS: TEST_ADDRESS,
|
||||||
|
|
|
@ -8,7 +8,7 @@ from motioneye_client.client import (
|
||||||
MotionEyeClientRequestError,
|
MotionEyeClientRequestError,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.hassio import HassioServiceInfo
|
from homeassistant.components.hassio import HassioServiceInfo
|
||||||
from homeassistant.components.motioneye.const import (
|
from homeassistant.components.motioneye.const import (
|
||||||
CONF_ADMIN_PASSWORD,
|
CONF_ADMIN_PASSWORD,
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.components.motioneye.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_URL, CONF_WEBHOOK_ID
|
from homeassistant.const import CONF_URL, CONF_WEBHOOK_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import TEST_URL, create_mock_motioneye_client, create_mock_motioneye_config_entry
|
from . import TEST_URL, create_mock_motioneye_client, create_mock_motioneye_config_entry
|
||||||
|
|
||||||
|
@ -88,12 +89,12 @@ async def test_hassio_success(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "hassio_confirm"
|
assert result.get("step_id") == "hassio_confirm"
|
||||||
assert result.get("description_placeholders") == {"addon": "motionEye"}
|
assert result.get("description_placeholders") == {"addon": "motionEye"}
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||||
assert result2.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
assert result2.get("step_id") == "user"
|
assert result2.get("step_id") == "user"
|
||||||
|
|
||||||
mock_client = create_mock_motioneye_client()
|
mock_client = create_mock_motioneye_client()
|
||||||
|
@ -119,7 +120,7 @@ async def test_hassio_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result3.get("title") == "Add-on"
|
assert result3.get("title") == "Add-on"
|
||||||
assert result3.get("data") == {
|
assert result3.get("data") == {
|
||||||
CONF_URL: TEST_URL,
|
CONF_URL: TEST_URL,
|
||||||
|
@ -300,7 +301,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert dict(config_entry.data) == {**new_data, CONF_WEBHOOK_ID: "test-webhook-id"}
|
assert dict(config_entry.data) == {**new_data, CONF_WEBHOOK_ID: "test-webhook-id"}
|
||||||
|
|
||||||
|
@ -350,7 +351,7 @@ async def test_duplicate(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert mock_client.async_client_close.called
|
assert mock_client.async_client_close.called
|
||||||
|
|
||||||
|
@ -372,7 +373,7 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -392,7 +393,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -401,7 +402,7 @@ async def test_hassio_abort_if_already_in_progress(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -413,7 +414,7 @@ async def test_hassio_abort_if_already_in_progress(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result2.get("type") == data_entry_flow.FlowResultType.ABORT
|
assert result2.get("type") is FlowResultType.ABORT
|
||||||
assert result2.get("reason") == "already_in_progress"
|
assert result2.get("reason") == "already_in_progress"
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,12 +431,12 @@ async def test_hassio_clean_up_on_user_flow(hass: HomeAssistant) -> None:
|
||||||
),
|
),
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
result2 = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result2.get("type") == data_entry_flow.FlowResultType.FORM
|
assert result2.get("type") is FlowResultType.FORM
|
||||||
|
|
||||||
mock_client = create_mock_motioneye_client()
|
mock_client = create_mock_motioneye_client()
|
||||||
|
|
||||||
|
@ -461,7 +462,7 @@ async def test_hassio_clean_up_on_user_flow(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
|
@ -487,7 +488,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -498,7 +499,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_WEBHOOK_SET]
|
assert result["data"][CONF_WEBHOOK_SET]
|
||||||
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
||||||
assert CONF_STREAM_URL_TEMPLATE not in result["data"]
|
assert CONF_STREAM_URL_TEMPLATE not in result["data"]
|
||||||
|
@ -533,7 +534,7 @@ async def test_advanced_options(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_WEBHOOK_SET]
|
assert result["data"][CONF_WEBHOOK_SET]
|
||||||
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
||||||
assert CONF_STREAM_URL_TEMPLATE not in result["data"]
|
assert CONF_STREAM_URL_TEMPLATE not in result["data"]
|
||||||
|
@ -552,7 +553,7 @@ async def test_advanced_options(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_WEBHOOK_SET]
|
assert result["data"][CONF_WEBHOOK_SET]
|
||||||
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
assert result["data"][CONF_WEBHOOK_SET_OVERWRITE]
|
||||||
assert result["data"][CONF_STREAM_URL_TEMPLATE] == "http://moo"
|
assert result["data"][CONF_STREAM_URL_TEMPLATE] == "http://moo"
|
||||||
|
|
|
@ -38,7 +38,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
|
|
||||||
async def test_user_connection_error(
|
async def test_user_connection_error(
|
||||||
|
@ -56,7 +56,7 @@ async def test_user_connection_error(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ async def test_user_connection_error_invalid_hostname(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ async def test_user_timeout_error(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "time_out"
|
assert result["reason"] == "time_out"
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ async def test_user_not_connected_error(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_connected"
|
assert result["reason"] == "not_connected"
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ async def test_user_response_error_single_device_old_ce_old_new_pro(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == HOST
|
assert result["title"] == HOST
|
||||||
|
|
||||||
assert result["data"]
|
assert result["data"]
|
||||||
|
@ -162,7 +162,7 @@ async def test_user_response_error_single_device_new_ce_old_pro(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ZEROCONF_NAME
|
assert result["title"] == ZEROCONF_NAME
|
||||||
|
|
||||||
assert result["data"]
|
assert result["data"]
|
||||||
|
@ -188,7 +188,7 @@ async def test_user_response_error_single_device_new_ce_new_pro(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ZEROCONF_NAME
|
assert result["title"] == ZEROCONF_NAME
|
||||||
|
|
||||||
assert result["data"]
|
assert result["data"]
|
||||||
|
@ -219,7 +219,7 @@ async def test_user_response_error_multi_device_old_ce_old_new_pro(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ async def test_user_response_error_multi_device_new_ce_new_pro(
|
||||||
data=user_input,
|
data=user_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ async def test_zeroconf_connection_error(
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ async def test_zeroconf_connection_error_invalid_hostname(
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ async def test_zeroconf_timout_error(
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "time_out"
|
assert result["reason"] == "time_out"
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ async def test_zeroconf_not_connected_error(
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_connected"
|
assert result["reason"] == "not_connected"
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ async def test_show_zeroconf_form_old_ce_old_pro(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "zeroconf_confirm"
|
assert result["step_id"] == "zeroconf_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ async def test_show_zeroconf_form_old_ce_new_pro(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "zeroconf_confirm"
|
assert result["step_id"] == "zeroconf_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ async def test_show_zeroconf_form_new_ce_old_pro(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "zeroconf_confirm"
|
assert result["step_id"] == "zeroconf_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ async def test_show_zeroconf_form_new_ce_new_pro(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "zeroconf_confirm"
|
assert result["step_id"] == "zeroconf_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
assert result["description_placeholders"] == {CONF_NAME: "My MotionMount"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ async def test_zeroconf_device_exists_abort(
|
||||||
data=discovery_info,
|
data=discovery_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,14 +437,14 @@ async def test_full_user_flow_implementation(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=MOCK_USER_INPUT.copy(),
|
user_input=MOCK_USER_INPUT.copy(),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ZEROCONF_NAME
|
assert result["title"] == ZEROCONF_NAME
|
||||||
|
|
||||||
assert result["data"]
|
assert result["data"]
|
||||||
|
@ -471,13 +471,13 @@ async def test_full_zeroconf_flow_implementation(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["step_id"] == "zeroconf_confirm"
|
assert result["step_id"] == "zeroconf_confirm"
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ZEROCONF_NAME
|
assert result["title"] == ZEROCONF_NAME
|
||||||
|
|
||||||
assert result["data"]
|
assert result["data"]
|
||||||
|
|
|
@ -11,10 +11,11 @@ from uuid import uuid4
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
from homeassistant.components.hassio import HassioServiceInfo
|
from homeassistant.components.hassio import HassioServiceInfo
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
|
from tests.typing import MqttMockHAClientGenerator, MqttMockPahoClient
|
||||||
|
@ -354,7 +355,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_HASSIO},
|
context={"source": config_entries.SOURCE_HASSIO},
|
||||||
)
|
)
|
||||||
assert result
|
assert result
|
||||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -473,7 +474,7 @@ async def test_option_flow(
|
||||||
mqtt_mock.async_connect.reset_mock()
|
mqtt_mock.async_connect.reset_mock()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -485,7 +486,7 @@ async def test_option_flow(
|
||||||
mqtt.CONF_PASSWORD: "pass",
|
mqtt.CONF_PASSWORD: "pass",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -510,7 +511,7 @@ async def test_option_flow(
|
||||||
"will_retain": True,
|
"will_retain": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {}
|
assert result["data"] == {}
|
||||||
assert config_entry.data == {
|
assert config_entry.data == {
|
||||||
mqtt.CONF_BROKER: "another-broker",
|
mqtt.CONF_BROKER: "another-broker",
|
||||||
|
@ -609,7 +610,7 @@ async def test_bad_certificate(
|
||||||
mqtt_mock.async_connect.reset_mock()
|
mqtt_mock.async_connect.reset_mock()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -682,7 +683,7 @@ async def test_keepalive_validation(
|
||||||
mqtt_mock.async_connect.reset_mock()
|
mqtt_mock.async_connect.reset_mock()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
if error:
|
if error:
|
||||||
|
@ -722,7 +723,7 @@ async def test_disable_birth_will(
|
||||||
mqtt_mock.async_connect.reset_mock()
|
mqtt_mock.async_connect.reset_mock()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -734,7 +735,7 @@ async def test_disable_birth_will(
|
||||||
mqtt.CONF_PASSWORD: "pass",
|
mqtt.CONF_PASSWORD: "pass",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -757,7 +758,7 @@ async def test_disable_birth_will(
|
||||||
"will_retain": True,
|
"will_retain": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {}
|
assert result["data"] == {}
|
||||||
assert config_entry.data == {
|
assert config_entry.data == {
|
||||||
mqtt.CONF_BROKER: "another-broker",
|
mqtt.CONF_BROKER: "another-broker",
|
||||||
|
@ -799,7 +800,7 @@ async def test_invalid_discovery_prefix(
|
||||||
mqtt_mock.async_connect.reset_mock()
|
mqtt_mock.async_connect.reset_mock()
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -809,7 +810,7 @@ async def test_invalid_discovery_prefix(
|
||||||
mqtt.CONF_PORT: 2345,
|
mqtt.CONF_PORT: 2345,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -822,7 +823,7 @@ async def test_invalid_discovery_prefix(
|
||||||
mqtt.CONF_DISCOVERY_PREFIX: "homeassistant#invalid",
|
mqtt.CONF_DISCOVERY_PREFIX: "homeassistant#invalid",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
assert result["errors"]["base"] == "bad_discovery_prefix"
|
assert result["errors"]["base"] == "bad_discovery_prefix"
|
||||||
assert config_entry.data == {
|
assert config_entry.data == {
|
||||||
|
@ -892,7 +893,7 @@ async def test_option_flow_default_suggested_values(
|
||||||
|
|
||||||
# Test default/suggested values from config
|
# Test default/suggested values from config
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
defaults = {
|
defaults = {
|
||||||
mqtt.CONF_BROKER: "test-broker",
|
mqtt.CONF_BROKER: "test-broker",
|
||||||
|
@ -916,7 +917,7 @@ async def test_option_flow_default_suggested_values(
|
||||||
mqtt.CONF_PASSWORD: "p4ss",
|
mqtt.CONF_PASSWORD: "p4ss",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
defaults = {
|
defaults = {
|
||||||
mqtt.CONF_DISCOVERY: True,
|
mqtt.CONF_DISCOVERY: True,
|
||||||
|
@ -950,11 +951,11 @@ async def test_option_flow_default_suggested_values(
|
||||||
"will_retain": True,
|
"will_retain": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
# Test updated default/suggested values from config
|
# Test updated default/suggested values from config
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
defaults = {
|
defaults = {
|
||||||
mqtt.CONF_BROKER: "another-broker",
|
mqtt.CONF_BROKER: "another-broker",
|
||||||
|
@ -973,7 +974,7 @@ async def test_option_flow_default_suggested_values(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={mqtt.CONF_BROKER: "another-broker", mqtt.CONF_PORT: 2345},
|
user_input={mqtt.CONF_BROKER: "another-broker", mqtt.CONF_PORT: 2345},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
defaults = {
|
defaults = {
|
||||||
mqtt.CONF_DISCOVERY: False,
|
mqtt.CONF_DISCOVERY: False,
|
||||||
|
@ -1007,7 +1008,7 @@ async def test_option_flow_default_suggested_values(
|
||||||
"will_retain": True,
|
"will_retain": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
# Make sure all MQTT related jobs are done before ending the test
|
# Make sure all MQTT related jobs are done before ending the test
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1049,7 +1050,7 @@ async def test_skipping_advanced_options(
|
||||||
result = await hass.config_entries.options.async_init(
|
result = await hass.config_entries.options.async_init(
|
||||||
config_entry.entry_id, context={"show_advanced_options": True}
|
config_entry.entry_id, context={"show_advanced_options": True}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -1221,7 +1222,7 @@ async def test_try_connection_with_advanced_parameters(
|
||||||
|
|
||||||
# Test default/suggested values from config
|
# Test default/suggested values from config
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "broker"
|
assert result["step_id"] == "broker"
|
||||||
defaults = {
|
defaults = {
|
||||||
mqtt.CONF_BROKER: "test-broker",
|
mqtt.CONF_BROKER: "test-broker",
|
||||||
|
@ -1261,7 +1262,7 @@ async def test_try_connection_with_advanced_parameters(
|
||||||
mqtt.CONF_WS_HEADERS: '{"h3": "v3"}',
|
mqtt.CONF_WS_HEADERS: '{"h3": "v3"}',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
assert result["step_id"] == "options"
|
assert result["step_id"] == "options"
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -1292,7 +1293,7 @@ async def test_try_connection_with_advanced_parameters(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={},
|
user_input={},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -50,7 +50,7 @@ async def test_form_user_only_once(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,5 +92,5 @@ async def test_unknown_error(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
|
@ -44,13 +44,13 @@ async def get_form(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.MENU
|
assert result["type"] is FlowResultType.MENU
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"next_step_id": GATEWAY_TYPE_TO_STEP[gateway_type]}
|
result["flow_id"], {"next_step_id": GATEWAY_TYPE_TO_STEP[gateway_type]}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == expected_step_id
|
assert result["step_id"] == expected_step_id
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -78,7 +78,7 @@ async def test_config_mqtt(hass: HomeAssistant, mqtt: None) -> None:
|
||||||
|
|
||||||
if "errors" in result:
|
if "errors" in result:
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "mqtt"
|
assert result["title"] == "mqtt"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_DEVICE: "mqtt",
|
CONF_DEVICE: "mqtt",
|
||||||
|
@ -96,7 +96,7 @@ async def test_missing_mqtt(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.MENU
|
assert result["type"] is FlowResultType.MENU
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
@ -104,7 +104,7 @@ async def test_missing_mqtt(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "mqtt_required"
|
assert result["reason"] == "mqtt_required"
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ async def test_config_serial(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
if "errors" in result:
|
if "errors" in result:
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "/dev/ttyACM0"
|
assert result["title"] == "/dev/ttyACM0"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_DEVICE: "/dev/ttyACM0",
|
CONF_DEVICE: "/dev/ttyACM0",
|
||||||
|
@ -177,7 +177,7 @@ async def test_config_tcp(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
if "errors" in result:
|
if "errors" in result:
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "127.0.0.1"
|
assert result["title"] == "127.0.0.1"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_DEVICE: "127.0.0.1",
|
CONF_DEVICE: "127.0.0.1",
|
||||||
|
@ -213,7 +213,7 @@ async def test_fail_to_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert "errors" in result
|
assert "errors" in result
|
||||||
errors = result["errors"]
|
errors = result["errors"]
|
||||||
assert errors
|
assert errors
|
||||||
|
@ -374,7 +374,7 @@ async def test_config_invalid(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert "errors" in result
|
assert "errors" in result
|
||||||
errors = result["errors"]
|
errors = result["errors"]
|
||||||
assert errors
|
assert errors
|
||||||
|
|
|
@ -22,7 +22,7 @@ async def test_form_combined(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ async def test_form_combined(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "myStrom Device"
|
assert result2["title"] == "myStrom Device"
|
||||||
assert result2["data"] == {"host": "1.1.1.1"}
|
assert result2["data"] == {"host": "1.1.1.1"}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ async def test_form_duplicates(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ async def test_form_duplicates(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
mock_session.assert_called_once()
|
mock_session.assert_called_once()
|
||||||
|
@ -78,7 +78,7 @@ async def test_wong_answer_from_device(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -93,7 +93,7 @@ async def test_wong_answer_from_device(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "user"
|
assert result2["step_id"] == "user"
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -108,6 +108,6 @@ async def test_wong_answer_from_device(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "myStrom Device"
|
assert result2["title"] == "myStrom Device"
|
||||||
assert result2["data"] == {"host": "1.1.1.1"}
|
assert result2["data"] == {"host": "1.1.1.1"}
|
||||||
|
|
|
@ -155,7 +155,7 @@ async def test_flow_reauth(
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "reauth_successful"
|
assert result.get("reason") == "reauth_successful"
|
||||||
|
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
|
@ -6,11 +6,11 @@ from unittest.mock import patch
|
||||||
from nettigo_air_monitor import ApiError, AuthFailedError, CannotGetMacError
|
from nettigo_air_monitor import ApiError, AuthFailedError, CannotGetMacError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.nam.const import DOMAIN
|
from homeassistant.components.nam.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ async def test_form_create_entry_without_auth(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ async def test_form_create_entry_without_auth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.2.3"
|
assert result["title"] == "10.10.2.3"
|
||||||
assert result["data"]["host"] == "10.10.2.3"
|
assert result["data"]["host"] == "10.10.2.3"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -68,7 +68,7 @@ async def test_form_create_entry_with_auth(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ async def test_form_create_entry_with_auth(hass: HomeAssistant) -> None:
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "credentials"
|
assert result["step_id"] == "credentials"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -99,7 +99,7 @@ async def test_form_create_entry_with_auth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.2.3"
|
assert result["title"] == "10.10.2.3"
|
||||||
assert result["data"]["host"] == "10.10.2.3"
|
assert result["data"]["host"] == "10.10.2.3"
|
||||||
assert result["data"]["username"] == "fake_username"
|
assert result["data"]["username"] == "fake_username"
|
||||||
|
@ -133,7 +133,7 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -141,7 +141,7 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
||||||
user_input=VALID_AUTH,
|
user_input=VALID_AUTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ async def test_reauth_unsuccessful(hass: HomeAssistant) -> None:
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -173,7 +173,7 @@ async def test_reauth_unsuccessful(hass: HomeAssistant) -> None:
|
||||||
user_input=VALID_AUTH,
|
user_input=VALID_AUTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_unsuccessful"
|
assert result["reason"] == "reauth_unsuccessful"
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ async def test_form_with_auth_errors(hass: HomeAssistant, error) -> None:
|
||||||
data=VALID_CONFIG,
|
data=VALID_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "credentials"
|
assert result["step_id"] == "credentials"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -262,7 +262,7 @@ async def test_form_abort(hass: HomeAssistant) -> None:
|
||||||
data=VALID_CONFIG,
|
data=VALID_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "device_unsupported"
|
assert result["reason"] == "device_unsupported"
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||||
{"host": "1.1.1.1"},
|
{"host": "1.1.1.1"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
# Test config entry got updated with latest IP
|
# Test config entry got updated with latest IP
|
||||||
|
@ -322,7 +322,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||||
if flow["flow_id"] == result["flow_id"]
|
if flow["flow_id"] == result["flow_id"]
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
assert context["title_placeholders"]["host"] == "10.10.2.3"
|
assert context["title_placeholders"]["host"] == "10.10.2.3"
|
||||||
assert context["confirm_only"] is True
|
assert context["confirm_only"] is True
|
||||||
|
@ -337,7 +337,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.2.3"
|
assert result["title"] == "10.10.2.3"
|
||||||
assert result["data"] == {"host": "10.10.2.3"}
|
assert result["data"] == {"host": "10.10.2.3"}
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
@ -366,7 +366,7 @@ async def test_zeroconf_with_auth(hass: HomeAssistant) -> None:
|
||||||
if flow["flow_id"] == result["flow_id"]
|
if flow["flow_id"] == result["flow_id"]
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "credentials"
|
assert result["step_id"] == "credentials"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
assert context["title_placeholders"]["host"] == "10.10.2.3"
|
assert context["title_placeholders"]["host"] == "10.10.2.3"
|
||||||
|
@ -390,7 +390,7 @@ async def test_zeroconf_with_auth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.2.3"
|
assert result["title"] == "10.10.2.3"
|
||||||
assert result["data"]["host"] == "10.10.2.3"
|
assert result["data"]["host"] == "10.10.2.3"
|
||||||
assert result["data"]["username"] == "fake_username"
|
assert result["data"]["username"] == "fake_username"
|
||||||
|
@ -411,7 +411,7 @@ async def test_zeroconf_host_already_configured(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -435,5 +435,5 @@ async def test_zeroconf_errors(hass: HomeAssistant, error) -> None:
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == reason
|
assert result["reason"] == reason
|
||||||
|
|
|
@ -4,13 +4,14 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pybotvac.neato import Neato
|
from pybotvac.neato import Neato
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
ClientCredential,
|
ClientCredential,
|
||||||
async_import_client_credential,
|
async_import_client_credential,
|
||||||
)
|
)
|
||||||
from homeassistant.components.neato.const import NEATO_DOMAIN
|
from homeassistant.components.neato.const import NEATO_DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -92,7 +93,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"neato", context={"source": config_entries.SOURCE_USER}
|
"neato", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ async def test_reauth(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"neato", context={"source": config_entries.SOURCE_REAUTH}
|
"neato", context={"source": config_entries.SOURCE_REAUTH}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
# Confirm reauth flow
|
# Confirm reauth flow
|
||||||
|
@ -155,7 +156,7 @@ async def test_reauth(
|
||||||
|
|
||||||
new_entry = hass.config_entries.async_get_entry("my_entry")
|
new_entry = hass.config_entries.async_get_entry("my_entry")
|
||||||
|
|
||||||
assert result3["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "reauth_successful"
|
assert result3["reason"] == "reauth_successful"
|
||||||
assert new_entry.state == config_entries.ConfigEntryState.LOADED
|
assert new_entry.state == config_entries.ConfigEntryState.LOADED
|
||||||
assert len(hass.config_entries.async_entries(NEATO_DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(NEATO_DOMAIN)) == 1
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pyatmo.const import ALL_SCOPES
|
from pyatmo.const import ALL_SCOPES
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.netatmo import config_flow
|
from homeassistant.components.netatmo import config_flow
|
||||||
from homeassistant.components.netatmo.const import (
|
from homeassistant.components.netatmo.const import (
|
||||||
|
@ -16,6 +16,7 @@ from homeassistant.components.netatmo.const import (
|
||||||
OAUTH2_TOKEN,
|
OAUTH2_TOKEN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
from .conftest import CLIENT_ID
|
from .conftest import CLIENT_ID
|
||||||
|
@ -37,7 +38,7 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"netatmo", context={"source": config_entries.SOURCE_USER}
|
"netatmo", context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
@ -53,7 +54,7 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||||
type="mock_type",
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,28 +141,28 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather_areas"
|
assert result["step_id"] == "public_weather_areas"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_NEW_AREA: "Home"}
|
result["flow_id"], user_input={CONF_NEW_AREA: "Home"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather"
|
assert result["step_id"] == "public_weather"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input=valid_option
|
result["flow_id"], user_input=valid_option
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather_areas"
|
assert result["step_id"] == "public_weather_areas"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
for k, v in expected_result.items():
|
for k, v in expected_result.items():
|
||||||
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
||||||
|
|
||||||
|
@ -198,28 +199,28 @@ async def test_option_flow_wrong_coordinates(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather_areas"
|
assert result["step_id"] == "public_weather_areas"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_NEW_AREA: "Home"}
|
result["flow_id"], user_input={CONF_NEW_AREA: "Home"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather"
|
assert result["step_id"] == "public_weather"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input=valid_option
|
result["flow_id"], user_input=valid_option
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "public_weather_areas"
|
assert result["step_id"] == "public_weather_areas"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
for k, v in expected_result.items():
|
for k, v in expected_result.items():
|
||||||
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
assert config_entry.options[CONF_WEATHER_AREAS]["Home"][k] == v
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ async def test_reauth(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"netatmo", context={"source": config_entries.SOURCE_REAUTH}
|
"netatmo", context={"source": config_entries.SOURCE_REAUTH}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
# Confirm reauth flow
|
# Confirm reauth flow
|
||||||
|
@ -319,7 +320,7 @@ async def test_reauth(
|
||||||
|
|
||||||
new_entry2 = hass.config_entries.async_entries(DOMAIN)[0]
|
new_entry2 = hass.config_entries.async_entries(DOMAIN)[0]
|
||||||
|
|
||||||
assert result3["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "reauth_successful"
|
assert result3["reason"] == "reauth_successful"
|
||||||
assert new_entry2.state == config_entries.ConfigEntryState.LOADED
|
assert new_entry2.state == config_entries.ConfigEntryState.LOADED
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
|
@ -5,7 +5,6 @@ from unittest.mock import Mock, patch
|
||||||
from pynetgear import DEFAULT_USER
|
from pynetgear import DEFAULT_USER
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.components.netgear.const import (
|
from homeassistant.components.netgear.const import (
|
||||||
CONF_CONSIDER_HOME,
|
CONF_CONSIDER_HOME,
|
||||||
|
@ -23,6 +22,7 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ async def test_user(hass: HomeAssistant, service) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# Have to provide all config
|
# Have to provide all config
|
||||||
|
@ -95,7 +95,7 @@ async def test_user(hass: HomeAssistant, service) -> None:
|
||||||
CONF_PASSWORD: PASSWORD,
|
CONF_PASSWORD: PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == SERIAL
|
assert result["result"].unique_id == SERIAL
|
||||||
assert result["title"] == TITLE
|
assert result["title"] == TITLE
|
||||||
assert result["data"].get(CONF_HOST) == HOST
|
assert result["data"].get(CONF_HOST) == HOST
|
||||||
|
@ -110,7 +110,7 @@ async def test_user_connect_error(hass: HomeAssistant, service) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
service.return_value.get_info = Mock(return_value=None)
|
service.return_value.get_info = Mock(return_value=None)
|
||||||
|
@ -124,7 +124,7 @@ async def test_user_connect_error(hass: HomeAssistant, service) -> None:
|
||||||
CONF_PASSWORD: PASSWORD,
|
CONF_PASSWORD: PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "info"}
|
assert result["errors"] == {"base": "info"}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ async def test_user_connect_error(hass: HomeAssistant, service) -> None:
|
||||||
CONF_PASSWORD: PASSWORD,
|
CONF_PASSWORD: PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "config"}
|
assert result["errors"] == {"base": "config"}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ async def test_user_incomplete_info(hass: HomeAssistant, service) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
router_infos = ROUTER_INFOS.copy()
|
router_infos = ROUTER_INFOS.copy()
|
||||||
|
@ -164,7 +164,7 @@ async def test_user_incomplete_info(hass: HomeAssistant, service) -> None:
|
||||||
CONF_PASSWORD: PASSWORD,
|
CONF_PASSWORD: PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == SERIAL
|
assert result["result"].unique_id == SERIAL
|
||||||
assert result["title"] == TITLE_INCOMPLETE
|
assert result["title"] == TITLE_INCOMPLETE
|
||||||
assert result["data"].get(CONF_HOST) == HOST
|
assert result["data"].get(CONF_HOST) == HOST
|
||||||
|
@ -186,14 +186,14 @@ async def test_abort_if_already_setup(hass: HomeAssistant, service) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
{CONF_PASSWORD: PASSWORD},
|
{CONF_PASSWORD: PASSWORD},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ async def test_ssdp_no_serial(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_serial"
|
assert result["reason"] == "no_serial"
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ async def test_ssdp_ipv6(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "not_ipv4_address"
|
assert result["reason"] == "not_ipv4_address"
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,13 +284,13 @@ async def test_ssdp(hass: HomeAssistant, service) -> None:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {CONF_PASSWORD: PASSWORD}
|
result["flow_id"], {CONF_PASSWORD: PASSWORD}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == SERIAL
|
assert result["result"].unique_id == SERIAL
|
||||||
assert result["title"] == TITLE
|
assert result["title"] == TITLE
|
||||||
assert result["data"].get(CONF_HOST) == HOST
|
assert result["data"].get(CONF_HOST) == HOST
|
||||||
|
@ -316,7 +316,7 @@ async def test_ssdp_port_5555(hass: HomeAssistant, service) -> None:
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
service.return_value.port = 5555
|
service.return_value.port = 5555
|
||||||
|
@ -325,7 +325,7 @@ async def test_ssdp_port_5555(hass: HomeAssistant, service) -> None:
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {CONF_PASSWORD: PASSWORD}
|
result["flow_id"], {CONF_PASSWORD: PASSWORD}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["result"].unique_id == SERIAL
|
assert result["result"].unique_id == SERIAL
|
||||||
assert result["title"] == TITLE
|
assert result["title"] == TITLE
|
||||||
assert result["data"].get(CONF_HOST) == HOST
|
assert result["data"].get(CONF_HOST) == HOST
|
||||||
|
@ -350,7 +350,7 @@ async def test_options_flow(hass: HomeAssistant, service) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -360,7 +360,7 @@ async def test_options_flow(hass: HomeAssistant, service) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_CONSIDER_HOME: 1800,
|
CONF_CONSIDER_HOME: 1800,
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ from homeassistant.components.netgear_lte.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||||
from homeassistant.const import CONF_SOURCE
|
from homeassistant.const import CONF_SOURCE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .conftest import CONF_DATA
|
from .conftest import CONF_DATA
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ async def test_flow_already_configured(
|
||||||
data=CONF_DATA,
|
data=CONF_DATA,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ async def test_import_config(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert (
|
assert (
|
||||||
result.get("title")
|
result.get("title")
|
||||||
== "San Francisco Muni F - Market & Wharves Market St & 7th St (Outbound)"
|
== "San Francisco Muni F - Market & Wharves Market St & 7th St (Outbound)"
|
||||||
|
@ -64,7 +64,7 @@ async def test_import_config(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == "already_configured"
|
assert result.get("reason") == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ async def test_import_config_invalid(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.ABORT
|
assert result.get("type") is FlowResultType.ABORT
|
||||||
assert result.get("reason") == expected_reason
|
assert result.get("reason") == expected_reason
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ async def test_user_config(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "agency"
|
assert result.get("step_id") == "agency"
|
||||||
|
|
||||||
# Select agency
|
# Select agency
|
||||||
|
@ -136,7 +136,7 @@ async def test_user_config(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "stop"
|
assert result.get("step_id") == "stop"
|
||||||
|
|
||||||
# Select stop
|
# Select stop
|
||||||
|
@ -148,7 +148,7 @@ async def test_user_config(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result.get("data") == {
|
assert result.get("data") == {
|
||||||
"agency": "sf-muni",
|
"agency": "sf-muni",
|
||||||
"route": "F",
|
"route": "F",
|
||||||
|
|
|
@ -36,7 +36,7 @@ async def test_user_create_entry(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ async def test_user_create_entry(
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ async def test_user_create_entry(
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "connection_error"}
|
assert result["errors"] == {"base": "connection_error"}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ async def test_user_create_entry(
|
||||||
VALID_CONFIG,
|
VALID_CONFIG,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "connection_error"}
|
assert result["errors"] == {"base": "connection_error"}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ async def test_user_create_entry(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "nc_url"
|
assert result["title"] == "nc_url"
|
||||||
assert result["data"] == snapshot
|
assert result["data"] == snapshot
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ async def test_user_already_configured(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ async def test_user_already_configured(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ async def test_reauth(
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
# test NextcloudMonitorAuthorizationError
|
# test NextcloudMonitorAuthorizationError
|
||||||
|
@ -165,7 +165,7 @@ async def test_reauth(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ async def test_reauth(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["errors"] == {"base": "connection_error"}
|
assert result["errors"] == {"base": "connection_error"}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ async def test_reauth(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["errors"] == {"base": "connection_error"}
|
assert result["errors"] == {"base": "connection_error"}
|
||||||
|
|
||||||
|
@ -217,6 +217,6 @@ async def test_reauth(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert entry.data == snapshot
|
assert entry.data == snapshot
|
||||||
|
|
|
@ -5,11 +5,11 @@ from unittest.mock import patch
|
||||||
from nextdns import ApiError, InvalidApiKeyError
|
from nextdns import ApiError, InvalidApiKeyError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.nextdns.const import CONF_PROFILE_ID, DOMAIN
|
from homeassistant.components.nextdns.const import CONF_PROFILE_ID, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_PROFILE_NAME
|
from homeassistant.const import CONF_API_KEY, CONF_PROFILE_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import PROFILES, init_integration
|
from . import PROFILES, init_integration
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ async def test_form_create_entry(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ async def test_form_create_entry(hass: HomeAssistant) -> None:
|
||||||
{CONF_API_KEY: "fake_api_key"},
|
{CONF_API_KEY: "fake_api_key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "profiles"
|
assert result["step_id"] == "profiles"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -45,7 +45,7 @@ async def test_form_create_entry(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "Fake Profile"
|
assert result["title"] == "Fake Profile"
|
||||||
assert result["data"][CONF_API_KEY] == "fake_api_key"
|
assert result["data"][CONF_API_KEY] == "fake_api_key"
|
||||||
assert result["data"][CONF_PROFILE_ID] == "xyz12"
|
assert result["data"][CONF_PROFILE_ID] == "xyz12"
|
||||||
|
@ -97,5 +97,5 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], {CONF_PROFILE_NAME: "Fake Profile"}
|
result["flow_id"], {CONF_PROFILE_NAME: "Fake Profile"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -4,9 +4,10 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from notifications_android_tv.notifications import ConnectError
|
from notifications_android_tv.notifications import ConnectError
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.nfandroidtv.const import DOMAIN
|
from homeassistant.components.nfandroidtv.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
CONF_CONFIG_FLOW,
|
CONF_CONFIG_FLOW,
|
||||||
|
@ -39,7 +40,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_CONFIG_FLOW,
|
user_input=CONF_CONFIG_FLOW,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == NAME
|
assert result["title"] == NAME
|
||||||
assert result["data"] == CONF_DATA
|
assert result["data"] == CONF_DATA
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=CONF_CONFIG_FLOW,
|
user_input=CONF_CONFIG_FLOW,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data=CONF_CONFIG_FLOW,
|
data=CONF_CONFIG_FLOW,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -93,6 +94,6 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data=CONF_CONFIG_FLOW,
|
data=CONF_CONFIG_FLOW,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
|
|
@ -43,13 +43,13 @@ async def _get_connection_form(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.MENU
|
assert result["type"] is FlowResultType.MENU
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"next_step_id": connection_type}
|
result["flow_id"], {"next_step_id": connection_type}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ async def test_nibegw_form(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "F1155 at 127.0.0.1"
|
assert result2["title"] == "F1155 at 127.0.0.1"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"model": "F1155",
|
"model": "F1155",
|
||||||
|
@ -94,7 +94,7 @@ async def test_modbus_form(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "S1155 at 127.0.0.1"
|
assert result2["title"] == "S1155 at 127.0.0.1"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"model": "S1155",
|
"model": "S1155",
|
||||||
|
@ -116,7 +116,7 @@ async def test_modbus_invalid_url(
|
||||||
result["flow_id"], {**MOCK_FLOW_MODBUS_USERDATA, "modbus_url": "invalid://url"}
|
result["flow_id"], {**MOCK_FLOW_MODBUS_USERDATA, "modbus_url": "invalid://url"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"modbus_url": "url"}
|
assert result2["errors"] == {"modbus_url": "url"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ async def test_nibegw_address_inuse(hass: HomeAssistant, mock_connection: Mock)
|
||||||
result["flow_id"], MOCK_FLOW_NIBEGW_USERDATA
|
result["flow_id"], MOCK_FLOW_NIBEGW_USERDATA
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"listening_port": "address_in_use"}
|
assert result2["errors"] == {"listening_port": "address_in_use"}
|
||||||
|
|
||||||
mock_connection.start.side_effect = Exception()
|
mock_connection.start.side_effect = Exception()
|
||||||
|
@ -140,7 +140,7 @@ async def test_nibegw_address_inuse(hass: HomeAssistant, mock_connection: Mock)
|
||||||
result["flow_id"], MOCK_FLOW_NIBEGW_USERDATA
|
result["flow_id"], MOCK_FLOW_NIBEGW_USERDATA
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ async def test_read_timeout(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "read"}
|
assert result2["errors"] == {"base": "read"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ async def test_write_timeout(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "write"}
|
assert result2["errors"] == {"base": "write"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ async def test_unexpected_exception(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ async def test_nibegw_invalid_host(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
if connection_type == "nibegw":
|
if connection_type == "nibegw":
|
||||||
assert result2["errors"] == {"ip_address": "address"}
|
assert result2["errors"] == {"ip_address": "address"}
|
||||||
else:
|
else:
|
||||||
|
@ -248,5 +248,5 @@ async def test_model_missing_coil(
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], data)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "model"}
|
assert result2["errors"] == {"base": "model"}
|
||||||
|
|
|
@ -5,11 +5,12 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from aiohttp import ClientConnectionError, ClientResponseError
|
from aiohttp import ClientConnectionError, ClientResponseError
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.nightscout.const import DOMAIN
|
from homeassistant.components.nightscout.const import DOMAIN
|
||||||
from homeassistant.components.nightscout.utils import hash_from_url
|
from homeassistant.components.nightscout.utils import hash_from_url
|
||||||
from homeassistant.const import CONF_URL
|
from homeassistant.const import CONF_URL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import GLUCOSE_READINGS, SERVER_STATUS, SERVER_STATUS_STATUS_ONLY
|
from . import GLUCOSE_READINGS, SERVER_STATUS, SERVER_STATUS_STATUS_ONLY
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -37,7 +38,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
CONFIG,
|
CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == SERVER_STATUS.name # pylint: disable=maybe-no-member
|
assert result2["title"] == SERVER_STATUS.name # pylint: disable=maybe-no-member
|
||||||
assert result2["data"] == CONFIG
|
assert result2["data"] == CONFIG
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -59,7 +60,7 @@ async def test_user_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
{CONF_URL: "https://some.url:1234"},
|
{CONF_URL: "https://some.url:1234"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ async def test_user_form_api_key_required(hass: HomeAssistant) -> None:
|
||||||
{CONF_URL: "https://some.url:1234"},
|
{CONF_URL: "https://some.url:1234"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ async def test_user_form_unexpected_exception(hass: HomeAssistant) -> None:
|
||||||
{CONF_URL: "https://some.url:1234"},
|
{CONF_URL: "https://some.url:1234"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +120,7 @@ async def test_user_form_duplicate(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_USER},
|
context={"source": config_entries.SOURCE_USER},
|
||||||
data=CONFIG,
|
data=CONFIG,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pynina import ApiError
|
from pynina import ApiError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.nina.const import (
|
from homeassistant.components.nina.const import (
|
||||||
CONF_AREA_FILTER,
|
CONF_AREA_FILTER,
|
||||||
CONF_HEADLINE_FILTER,
|
CONF_HEADLINE_FILTER,
|
||||||
|
@ -25,6 +24,7 @@ from homeassistant.components.nina.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
from . import mocked_request_function
|
from . import mocked_request_function
|
||||||
|
@ -61,7 +61,7 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ async def test_step_user_connection_error(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ async def test_step_user_unexpected_exception(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
|
||||||
|
|
||||||
async def test_step_user(hass: HomeAssistant) -> None:
|
async def test_step_user(hass: HomeAssistant) -> None:
|
||||||
|
@ -108,7 +108,7 @@ async def test_step_user(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "NINA"
|
assert result["title"] == "NINA"
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ async def test_step_user_no_selection(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HEADLINE_FILTER: ""}
|
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HEADLINE_FILTER: ""}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "no_selection"}
|
assert result["errors"] == {"base": "no_selection"}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ async def test_step_user_already_configured(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
DOMAIN, context={"source": SOURCE_USER}, data=deepcopy(DUMMY_DATA)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ async def test_options_flow_init(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -187,7 +187,7 @@ async def test_options_flow_init(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] is None
|
assert result["data"] is None
|
||||||
|
|
||||||
assert dict(config_entry.data) == {
|
assert dict(config_entry.data) == {
|
||||||
|
@ -227,7 +227,7 @@ async def test_options_flow_with_no_selection(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -243,7 +243,7 @@ async def test_options_flow_with_no_selection(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert result["errors"] == {"base": "no_selection"}
|
assert result["errors"] == {"base": "no_selection"}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ async def test_options_flow_connection_error(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ async def test_options_flow_unexpected_exception(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow_entity_removal(hass: HomeAssistant) -> None:
|
async def test_options_flow_entity_removal(hass: HomeAssistant) -> None:
|
||||||
|
@ -339,7 +339,7 @@ async def test_options_flow_entity_removal(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
entity_registry: er = er.async_get(hass)
|
entity_registry: er = er.async_get(hass)
|
||||||
entries = er.async_entries_for_config_entry(
|
entries = er.async_entries_for_config_entry(
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.device_tracker import (
|
from homeassistant.components.device_tracker import (
|
||||||
CONF_CONSIDER_HOME,
|
CONF_CONSIDER_HOME,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
|
@ -17,6 +17,7 @@ from homeassistant.components.nmap_tracker.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_EXCLUDE, CONF_HOSTS
|
from homeassistant.const import CONF_EXCLUDE, CONF_HOSTS
|
||||||
from homeassistant.core import CoreState, HomeAssistant
|
from homeassistant.core import CoreState, HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -203,7 +204,7 @@ async def test_options_flow(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
assert result["data_schema"]({}) == {
|
assert result["data_schema"]({}) == {
|
||||||
|
@ -232,7 +233,7 @@ async def test_options_flow(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_HOSTS: "192.168.1.0/24,192.168.2.0/24",
|
CONF_HOSTS: "192.168.1.0/24,192.168.2.0/24",
|
||||||
CONF_HOME_INTERVAL: 5,
|
CONF_HOME_INTERVAL: 5,
|
||||||
|
|
|
@ -5,11 +5,11 @@ from unittest.mock import AsyncMock, patch
|
||||||
from aionotion.errors import InvalidCredentialsError, NotionError
|
from aionotion.errors import InvalidCredentialsError, NotionError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN
|
from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .conftest import TEST_PASSWORD, TEST_REFRESH_TOKEN, TEST_USER_UUID, TEST_USERNAME
|
from .conftest import TEST_PASSWORD, TEST_REFRESH_TOKEN, TEST_USER_UUID, TEST_USERNAME
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ async def test_create_entry(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# Test errors that can arise when getting a Notion API client:
|
# Test errors that can arise when getting a Notion API client:
|
||||||
|
@ -51,7 +51,7 @@ async def test_create_entry(
|
||||||
CONF_PASSWORD: TEST_PASSWORD,
|
CONF_PASSWORD: TEST_PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == errors
|
assert result["errors"] == errors
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -61,7 +61,7 @@ async def test_create_entry(
|
||||||
CONF_PASSWORD: TEST_PASSWORD,
|
CONF_PASSWORD: TEST_PASSWORD,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == TEST_USERNAME
|
assert result["title"] == TEST_USERNAME
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_REFRESH_TOKEN: TEST_REFRESH_TOKEN,
|
CONF_REFRESH_TOKEN: TEST_REFRESH_TOKEN,
|
||||||
|
@ -75,7 +75,7 @@ async def test_duplicate_error(hass: HomeAssistant, config, config_entry) -> Non
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=config
|
DOMAIN, context={"source": SOURCE_USER}, data=config
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ async def test_reauth(
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_PASSWORD: "password"}
|
result["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == errors
|
assert result["errors"] == errors
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -126,6 +126,6 @@ async def test_reauth(
|
||||||
# to setup the config entry via reload.
|
# to setup the config entry via reload.
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert len(hass.config_entries.async_entries()) == 1
|
assert len(hass.config_entries.async_entries()) == 1
|
||||||
|
|
|
@ -5,11 +5,12 @@ from unittest.mock import patch
|
||||||
from pynuki.bridge import InvalidCredentialsException
|
from pynuki.bridge import InvalidCredentialsException
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.components.nuki.const import DOMAIN
|
from homeassistant.components.nuki.const import DOMAIN
|
||||||
from homeassistant.const import CONF_TOKEN
|
from homeassistant.const import CONF_TOKEN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .mock import DHCP_FORMATTED_MAC, HOST, MOCK_INFO, NAME, setup_nuki_integration
|
from .mock import DHCP_FORMATTED_MAC, HOST, MOCK_INFO, NAME, setup_nuki_integration
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -43,7 +44,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "75BCD15"
|
assert result2["title"] == "75BCD15"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
|
@ -72,7 +73,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,7 +143,7 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_DHCP},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == config_entries.SOURCE_USER
|
assert result["step_id"] == config_entries.SOURCE_USER
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -178,7 +179,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "75BCD15"
|
assert result2["title"] == "75BCD15"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"host": "1.1.1.1",
|
"host": "1.1.1.1",
|
||||||
|
@ -201,7 +202,7 @@ async def test_dhcp_flow_already_configured(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_DHCP},
|
context={"source": config_entries.SOURCE_DHCP},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -231,7 +232,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
assert entry.data[CONF_TOKEN] == "new-token"
|
assert entry.data[CONF_TOKEN] == "new-token"
|
||||||
|
|
||||||
|
@ -243,7 +244,7 @@ async def test_reauth_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -255,7 +256,7 @@ async def test_reauth_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_TOKEN: "new-token"},
|
user_input={CONF_TOKEN: "new-token"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "reauth_confirm"
|
assert result2["step_id"] == "reauth_confirm"
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
@ -267,7 +268,7 @@ async def test_reauth_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -279,7 +280,7 @@ async def test_reauth_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_TOKEN: "new-token"},
|
user_input={CONF_TOKEN: "new-token"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "reauth_confirm"
|
assert result2["step_id"] == "reauth_confirm"
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -291,7 +292,7 @@ async def test_reauth_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -303,6 +304,6 @@ async def test_reauth_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_TOKEN: "new-token"},
|
user_input={CONF_TOKEN: "new-token"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "reauth_confirm"
|
assert result2["step_id"] == "reauth_confirm"
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from aionut import NUTError, NUTLoginError
|
from aionut import NUTError, NUTLoginError
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.nut.const import DOMAIN
|
from homeassistant.components.nut.const import DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .util import _get_mock_nutclient
|
from .util import _get_mock_nutclient
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ async def test_form_zeroconf(hass: HomeAssistant) -> None:
|
||||||
type="mock_type",
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ async def test_form_zeroconf(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "192.168.1.5:1234"
|
assert result2["title"] == "192.168.1.5:1234"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: "192.168.1.5",
|
CONF_HOST: "192.168.1.5",
|
||||||
|
@ -89,7 +90,7 @@ async def test_form_user_one_ups(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -117,7 +118,7 @@ async def test_form_user_one_ups(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "1.1.1.1:2222"
|
assert result2["title"] == "1.1.1.1:2222"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: "1.1.1.1",
|
CONF_HOST: "1.1.1.1",
|
||||||
|
@ -141,7 +142,7 @@ async def test_form_user_multiple_ups(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -164,7 +165,7 @@ async def test_form_user_multiple_ups(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["step_id"] == "ups"
|
assert result2["step_id"] == "ups"
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -182,7 +183,7 @@ async def test_form_user_multiple_ups(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "ups2@1.1.1.1:2222"
|
assert result3["title"] == "ups2@1.1.1.1:2222"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
CONF_HOST: "1.1.1.1",
|
CONF_HOST: "1.1.1.1",
|
||||||
|
@ -205,7 +206,7 @@ async def test_form_user_one_ups_with_ignored_entry(hass: HomeAssistant) -> None
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -233,7 +234,7 @@ async def test_form_user_one_ups_with_ignored_entry(hass: HomeAssistant) -> None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "1.1.1.1:2222"
|
assert result2["title"] == "1.1.1.1:2222"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: "1.1.1.1",
|
CONF_HOST: "1.1.1.1",
|
||||||
|
@ -266,7 +267,7 @@ async def test_form_no_upses_found(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "no_ups_found"
|
assert result2["reason"] == "no_ups_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -296,7 +297,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
assert result2["description_placeholders"] == {"error": "no route to host"}
|
assert result2["description_placeholders"] == {"error": "no route to host"}
|
||||||
|
|
||||||
|
@ -320,7 +321,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -347,7 +348,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "1.1.1.1:2222"
|
assert result2["title"] == "1.1.1.1:2222"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: "1.1.1.1",
|
CONF_HOST: "1.1.1.1",
|
||||||
|
@ -384,7 +385,7 @@ async def test_auth_failures(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"password": "invalid_auth"}
|
assert result2["errors"] == {"password": "invalid_auth"}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -411,7 +412,7 @@ async def test_auth_failures(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "1.1.1.1:2222"
|
assert result2["title"] == "1.1.1.1:2222"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
CONF_HOST: "1.1.1.1",
|
CONF_HOST: "1.1.1.1",
|
||||||
|
@ -457,7 +458,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"password": "invalid_auth"}
|
assert result2["errors"] == {"password": "invalid_auth"}
|
||||||
|
|
||||||
mock_pynut = _get_mock_nutclient(
|
mock_pynut = _get_mock_nutclient(
|
||||||
|
@ -482,7 +483,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] is data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "reauth_successful"
|
assert result2["reason"] == "reauth_successful"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
@ -520,7 +521,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,7 +560,7 @@ async def test_abort_if_already_setup_alias(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["step_id"] == "ups"
|
assert result2["step_id"] == "ups"
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.nut.AIONUTClient",
|
"homeassistant.components.nut.AIONUTClient",
|
||||||
|
@ -570,7 +571,7 @@ async def test_abort_if_already_setup_alias(hass: HomeAssistant) -> None:
|
||||||
{CONF_ALIAS: "ups1"},
|
{CONF_ALIAS: "ups1"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "already_configured"
|
assert result3["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -587,14 +588,14 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
with patch("homeassistant.components.nut.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.nut.async_setup_entry", return_value=True):
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={}
|
result["flow_id"], user_input={}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_SCAN_INTERVAL: 60,
|
CONF_SCAN_INTERVAL: 60,
|
||||||
}
|
}
|
||||||
|
@ -602,7 +603,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
with patch("homeassistant.components.nut.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.nut.async_setup_entry", return_value=True):
|
||||||
result2 = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result2 = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "init"
|
assert result2["step_id"] == "init"
|
||||||
|
|
||||||
result2 = await hass.config_entries.options.async_configure(
|
result2 = await hass.config_entries.options.async_configure(
|
||||||
|
@ -610,7 +611,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
user_input={CONF_SCAN_INTERVAL: 12},
|
user_input={CONF_SCAN_INTERVAL: 12},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_SCAN_INTERVAL: 12,
|
CONF_SCAN_INTERVAL: 12,
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -43,7 +43,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.10.30"
|
assert result["title"] == "10.10.10.30"
|
||||||
assert result["data"] == {**USER_INPUT, CONF_VERIFY_SSL: False}
|
assert result["data"] == {**USER_INPUT, CONF_VERIFY_SSL: False}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ async def test_user_form_show_advanced_options(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}
|
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
user_input_advanced = {
|
user_input_advanced = {
|
||||||
|
@ -76,7 +76,7 @@ async def test_user_form_show_advanced_options(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.10.30"
|
assert result["title"] == "10.10.10.30"
|
||||||
assert result["data"] == {**USER_INPUT, CONF_VERIFY_SSL: True}
|
assert result["data"] == {**USER_INPUT, CONF_VERIFY_SSL: True}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ async def test_user_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ async def test_user_form_unexpected_exception(hass: HomeAssistant) -> None:
|
||||||
USER_INPUT,
|
USER_INPUT,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "unknown"
|
assert result["reason"] == "unknown"
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,5 +131,5 @@ async def test_user_form_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||||
context={"source": SOURCE_USER},
|
context={"source": SOURCE_USER},
|
||||||
data=USER_INPUT,
|
data=USER_INPUT,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
|
@ -24,7 +24,7 @@ async def test_user_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ async def test_user_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "10.10.10.30"
|
assert result["title"] == "10.10.10.30"
|
||||||
assert result["data"] == {**USER_INPUT}
|
assert result["data"] == {**USER_INPUT}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ async def test_auth_failure(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "invalid_auth"
|
assert result["errors"]["base"] == "invalid_auth"
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ async def test_connect_failure(hass: HomeAssistant, mock_gaierror: Generator) ->
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"]["base"] == "cannot_connect"
|
assert result["errors"]["base"] == "cannot_connect"
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert len(flows) == 1
|
assert len(flows) == 1
|
||||||
assert (
|
assert (
|
||||||
get_schema_suggestion(result["data_schema"].schema, CONF_USERNAME)
|
get_schema_suggestion(result["data_schema"].schema, CONF_USERNAME)
|
||||||
|
@ -114,7 +114,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
|
|
||||||
async def test_dhcp_flow_auth_failure(hass: HomeAssistant) -> None:
|
async def test_dhcp_flow_auth_failure(hass: HomeAssistant) -> None:
|
||||||
|
|
|
@ -5,10 +5,11 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from pyoctoprintapi import ApiError, DiscoverySettings
|
from pyoctoprintapi import ApiError, DiscoverySettings
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import ssdp, zeroconf
|
from homeassistant.components import ssdp, zeroconf
|
||||||
from homeassistant.components.octoprint.const import DOMAIN
|
from homeassistant.components.octoprint.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -242,7 +243,7 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
|
|
||||||
async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||||
|
@ -311,7 +312,7 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
|
|
||||||
|
|
||||||
async def test_import_yaml(hass: HomeAssistant) -> None:
|
async def test_import_yaml(hass: HomeAssistant) -> None:
|
||||||
|
@ -347,7 +348,7 @@ async def test_import_yaml(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert "errors" not in result
|
assert "errors" not in result
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ async def test_import_duplicate_yaml(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(request_app_key.mock_calls) == 0
|
assert len(request_app_key.mock_calls) == 0
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -49,13 +49,13 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# Step 2: model
|
# Step 2: model
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
ollama.CONF_URL: "http://localhost:11434",
|
ollama.CONF_URL: "http://localhost:11434",
|
||||||
ollama.CONF_MODEL: TEST_MODEL,
|
ollama.CONF_MODEL: TEST_MODEL,
|
||||||
|
@ -75,7 +75,7 @@ async def test_form_need_download(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
ollama.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
pull_ready = asyncio.Event()
|
pull_ready = asyncio.Event()
|
||||||
|
@ -113,14 +113,14 @@ async def test_form_need_download(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# Step 2: model
|
# Step 2: model
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# Step 3: download
|
# Step 3: download
|
||||||
assert result3["type"] == FlowResultType.SHOW_PROGRESS
|
assert result3["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
result4 = await hass.config_entries.flow.async_configure(
|
result4 = await hass.config_entries.flow.async_configure(
|
||||||
result3["flow_id"],
|
result3["flow_id"],
|
||||||
)
|
)
|
||||||
|
@ -128,12 +128,12 @@ async def test_form_need_download(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
# Run again without the task finishing.
|
# Run again without the task finishing.
|
||||||
# We should still be downloading.
|
# We should still be downloading.
|
||||||
assert result4["type"] == FlowResultType.SHOW_PROGRESS
|
assert result4["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
result4 = await hass.config_entries.flow.async_configure(
|
result4 = await hass.config_entries.flow.async_configure(
|
||||||
result4["flow_id"],
|
result4["flow_id"],
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result4["type"] == FlowResultType.SHOW_PROGRESS
|
assert result4["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
|
|
||||||
# Signal fake pull method to complete
|
# Signal fake pull method to complete
|
||||||
pull_ready.set()
|
pull_ready.set()
|
||||||
|
@ -147,7 +147,7 @@ async def test_form_need_download(hass: HomeAssistant) -> None:
|
||||||
result4["flow_id"],
|
result4["flow_id"],
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result5["type"] == FlowResultType.CREATE_ENTRY
|
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result5["data"] == {
|
assert result5["data"] == {
|
||||||
ollama.CONF_URL: "http://localhost:11434",
|
ollama.CONF_URL: "http://localhost:11434",
|
||||||
ollama.CONF_MODEL: TEST_MODEL,
|
ollama.CONF_MODEL: TEST_MODEL,
|
||||||
|
@ -167,7 +167,7 @@ async def test_options(
|
||||||
{ollama.CONF_PROMPT: "test prompt", ollama.CONF_MAX_HISTORY: 100},
|
{ollama.CONF_PROMPT: "test prompt", ollama.CONF_MAX_HISTORY: 100},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert options["type"] == FlowResultType.CREATE_ENTRY
|
assert options["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert options["data"] == {
|
assert options["data"] == {
|
||||||
ollama.CONF_PROMPT: "test prompt",
|
ollama.CONF_PROMPT: "test prompt",
|
||||||
ollama.CONF_MAX_HISTORY: 100,
|
ollama.CONF_MAX_HISTORY: 100,
|
||||||
|
@ -195,7 +195,7 @@ async def test_form_errors(hass: HomeAssistant, side_effect, error) -> None:
|
||||||
result["flow_id"], {ollama.CONF_URL: "http://localhost:11434"}
|
result["flow_id"], {ollama.CONF_URL: "http://localhost:11434"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": error}
|
assert result2["errors"] == {"base": error}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,15 +220,15 @@ async def test_download_error(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
result2["flow_id"], {ollama.CONF_MODEL: TEST_MODEL}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.SHOW_PROGRESS
|
assert result3["type"] is FlowResultType.SHOW_PROGRESS
|
||||||
result4 = await hass.config_entries.flow.async_configure(result3["flow_id"])
|
result4 = await hass.config_entries.flow.async_configure(result3["flow_id"])
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result4["type"] == FlowResultType.ABORT
|
assert result4["type"] is FlowResultType.ABORT
|
||||||
assert result4["reason"] == "download_failed"
|
assert result4["reason"] == "download_failed"
|
||||||
|
|
|
@ -4,9 +4,10 @@ from unittest.mock import patch
|
||||||
|
|
||||||
from omnilogic import LoginException, OmniLogicException
|
from omnilogic import LoginException, OmniLogicException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.omnilogic.const import DOMAIN
|
from homeassistant.components.omnilogic.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||||
data=None,
|
data=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -142,6 +143,6 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||||
user_input={"polling_interval": 9},
|
user_input={"polling_interval": 9},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == ""
|
assert result["title"] == ""
|
||||||
assert result["data"]["polling_interval"] == 9
|
assert result["data"]["polling_interval"] == 9
|
||||||
|
|
|
@ -17,7 +17,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -36,7 +36,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "test-username"
|
assert result2["title"] == "test-username"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"username": "TEST-username",
|
"username": "TEST-username",
|
||||||
|
@ -63,7 +63,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,5 +136,5 @@ async def test_already_configured(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.ondilo_ico.const import (
|
from homeassistant.components.ondilo_ico.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
OAUTH2_AUTHORIZE,
|
OAUTH2_AUTHORIZE,
|
||||||
|
@ -12,6 +12,7 @@ from homeassistant.components.ondilo_ico.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -29,7 +30,7 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ async def test_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
# Invalid server
|
# Invalid server
|
||||||
|
@ -54,7 +54,7 @@ async def test_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ async def test_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||||
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "1.2.3.4"
|
assert result["title"] == "1.2.3.4"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_HOST: "1.2.3.4",
|
CONF_HOST: "1.2.3.4",
|
||||||
|
@ -89,7 +89,7 @@ async def test_user_duplicate(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ async def test_user_duplicate(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 1234},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ async def test_user_options_clear(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={INPUT_ENTRY_CLEAR_OPTIONS: True},
|
user_input={INPUT_ENTRY_CLEAR_OPTIONS: True},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {}
|
assert result["data"] == {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ async def test_user_options_empty_selection(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={INPUT_ENTRY_DEVICE_SELECTION: []},
|
user_input={INPUT_ENTRY_DEVICE_SELECTION: []},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "device_selection"
|
assert result["step_id"] == "device_selection"
|
||||||
assert result["errors"] == {"base": "device_not_selected"}
|
assert result["errors"] == {"base": "device_not_selected"}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ async def test_user_options_set_single(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={INPUT_ENTRY_DEVICE_SELECTION: ["28.111111111111"]},
|
user_input={INPUT_ENTRY_DEVICE_SELECTION: ["28.111111111111"]},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["description_placeholders"]["sensor_id"] == "28.111111111111"
|
assert result["description_placeholders"]["sensor_id"] == "28.111111111111"
|
||||||
|
|
||||||
# Verify that the setting for the device comes back as default when no input is given
|
# Verify that the setting for the device comes back as default when no input is given
|
||||||
|
@ -182,7 +182,7 @@ async def test_user_options_set_single(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={},
|
user_input={},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert (
|
assert (
|
||||||
result["data"]["device_options"]["28.111111111111"]["precision"]
|
result["data"]["device_options"]["28.111111111111"]["precision"]
|
||||||
== "temperature"
|
== "temperature"
|
||||||
|
@ -220,7 +220,7 @@ async def test_user_options_set_multiple(
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert (
|
assert (
|
||||||
result["description_placeholders"]["sensor_id"]
|
result["description_placeholders"]["sensor_id"]
|
||||||
== "Given Name (28.222222222222)"
|
== "Given Name (28.222222222222)"
|
||||||
|
@ -231,7 +231,7 @@ async def test_user_options_set_multiple(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"precision": "temperature"},
|
user_input={"precision": "temperature"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert (
|
assert (
|
||||||
result["description_placeholders"]["sensor_id"]
|
result["description_placeholders"]["sensor_id"]
|
||||||
== "Given Name (28.111111111111)"
|
== "Given Name (28.111111111111)"
|
||||||
|
@ -242,7 +242,7 @@ async def test_user_options_set_multiple(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"precision": "temperature9"},
|
user_input={"precision": "temperature9"},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert (
|
assert (
|
||||||
result["data"]["device_options"]["28.222222222222"]["precision"]
|
result["data"]["device_options"]["28.222222222222"]["precision"]
|
||||||
== "temperature"
|
== "temperature"
|
||||||
|
@ -262,5 +262,5 @@ async def test_user_options_no_devices(
|
||||||
# Verify that first config step comes back with an empty list of possible devices to choose from
|
# Verify that first config step comes back with an empty list of possible devices to choose from
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "No configurable devices found."
|
assert result["reason"] == "No configurable devices found."
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components import dhcp
|
from homeassistant.components import dhcp
|
||||||
from homeassistant.components.onvif import DOMAIN, config_flow
|
from homeassistant.components.onvif import DOMAIN, config_flow
|
||||||
from homeassistant.config_entries import SOURCE_DHCP
|
from homeassistant.config_entries import SOURCE_DHCP
|
||||||
|
@ -107,7 +107,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -127,7 +127,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={"auto": True}
|
result["flow_id"], user_input={"auto": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "device"
|
assert result["step_id"] == "device"
|
||||||
container = result["data_schema"].schema[config_flow.CONF_HOST].container
|
container = result["data_schema"].schema[config_flow.CONF_HOST].container
|
||||||
assert len(container) == 3
|
assert len(container) == 3
|
||||||
|
@ -141,7 +141,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={config_flow.CONF_HOST: HOST}
|
result["flow_id"], user_input={config_flow.CONF_HOST: HOST}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -158,7 +158,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"{URN} - {MAC}"
|
assert result["title"] == f"{URN} - {MAC}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
config_flow.CONF_NAME: URN,
|
config_flow.CONF_NAME: URN,
|
||||||
|
@ -180,7 +180,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -200,7 +200,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||||
result["flow_id"], user_input={"auto": True}
|
result["flow_id"], user_input={"auto": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "device"
|
assert result["step_id"] == "device"
|
||||||
assert len(result["data_schema"].schema[config_flow.CONF_HOST].container) == 2
|
assert len(result["data_schema"].schema[config_flow.CONF_HOST].container) == 2
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||||
user_input={config_flow.CONF_HOST: config_flow.CONF_MANUAL_INPUT},
|
user_input={config_flow.CONF_HOST: config_flow.CONF_MANUAL_INPUT},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ async def test_flow_discovered_no_device(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -241,7 +241,7 @@ async def test_flow_discovered_no_device(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={"auto": True}
|
result["flow_id"], user_input={"auto": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -287,7 +287,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||||
)
|
)
|
||||||
|
|
||||||
# It should skip to manual entry if the only devices are already configured
|
# It should skip to manual entry if the only devices are already configured
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -302,7 +302,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||||
)
|
)
|
||||||
|
|
||||||
# It should abort if already configured and entered manually
|
# It should abort if already configured and entered manually
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||||
|
@ -312,7 +312,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -334,7 +334,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||||
user_input={"auto": False},
|
user_input={"auto": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -354,7 +354,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"{NAME} - {MAC}"
|
assert result["title"] == f"{NAME} - {MAC}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
config_flow.CONF_NAME: NAME,
|
config_flow.CONF_NAME: NAME,
|
||||||
|
@ -371,7 +371,7 @@ async def test_flow_manual_entry_no_profiles(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -403,7 +403,7 @@ async def test_flow_manual_entry_no_profiles(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_h264"
|
assert result["reason"] == "no_h264"
|
||||||
|
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ async def test_flow_manual_entry_no_mac(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -447,7 +447,7 @@ async def test_flow_manual_entry_no_mac(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_mac"
|
assert result["reason"] == "no_mac"
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -481,7 +481,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||||
user_input={"auto": False},
|
user_input={"auto": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -501,7 +501,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
assert result["errors"] == {"base": "onvif_error"}
|
assert result["errors"] == {"base": "onvif_error"}
|
||||||
assert result["description_placeholders"] == {"error": "camera not ready"}
|
assert result["description_placeholders"] == {"error": "camera not ready"}
|
||||||
|
@ -526,7 +526,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
assert result["errors"] == {"base": "onvif_error"}
|
assert result["errors"] == {"base": "onvif_error"}
|
||||||
assert result["description_placeholders"] == {
|
assert result["description_placeholders"] == {
|
||||||
|
@ -567,7 +567,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -589,7 +589,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||||
user_input={"auto": False},
|
user_input={"auto": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -609,7 +609,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
assert result["errors"] == {"password": "auth_failed"}
|
assert result["errors"] == {"password": "auth_failed"}
|
||||||
assert result["description_placeholders"] == {"error": "Authority failure"}
|
assert result["description_placeholders"] == {"error": "Authority failure"}
|
||||||
|
@ -651,7 +651,7 @@ async def test_option_flow(hass: HomeAssistant, option_value: bool) -> None:
|
||||||
entry.entry_id, context={"show_advanced_options": True}
|
entry.entry_id, context={"show_advanced_options": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "onvif_devices"
|
assert result["step_id"] == "onvif_devices"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -664,7 +664,7 @@ async def test_option_flow(hass: HomeAssistant, option_value: bool) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
config_flow.CONF_EXTRA_ARGUMENTS: "",
|
config_flow.CONF_EXTRA_ARGUMENTS: "",
|
||||||
config_flow.CONF_RTSP_TRANSPORT: list(config_flow.RTSP_TRANSPORTS)[1],
|
config_flow.CONF_RTSP_TRANSPORT: list(config_flow.RTSP_TRANSPORTS)[1],
|
||||||
|
@ -691,7 +691,7 @@ async def test_discovered_by_dhcp_updates_host(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert config_entry.data[CONF_HOST] == DHCP_DISCOVERY.ip
|
assert config_entry.data[CONF_HOST] == DHCP_DISCOVERY.ip
|
||||||
|
|
||||||
|
@ -716,7 +716,7 @@ async def test_discovered_by_dhcp_does_nothing_if_host_is_the_same(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert config_entry.data[CONF_HOST] == DHCP_DISCOVERY_SAME_IP.ip
|
assert config_entry.data[CONF_HOST] == DHCP_DISCOVERY_SAME_IP.ip
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ async def test_discovered_by_dhcp_does_not_update_if_already_loaded(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert config_entry.data[CONF_HOST] != DHCP_DISCOVERY.ip
|
assert config_entry.data[CONF_HOST] != DHCP_DISCOVERY.ip
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ async def test_discovered_by_dhcp_does_not_update_if_no_matching_entry(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "no_devices_found"
|
assert result["reason"] == "no_devices_found"
|
||||||
|
|
||||||
|
|
||||||
|
@ -775,7 +775,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||||
context={"source": config_entries.SOURCE_REAUTH, "entry_id": entry.entry_id},
|
context={"source": config_entries.SOURCE_REAUTH, "entry_id": entry.entry_id},
|
||||||
data=entry.data,
|
data=entry.data,
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert (
|
assert (
|
||||||
_get_schema_default(result["data_schema"].schema, CONF_USERNAME)
|
_get_schema_default(result["data_schema"].schema, CONF_USERNAME)
|
||||||
|
@ -804,7 +804,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["step_id"] == "reauth_confirm"
|
assert result2["step_id"] == "reauth_confirm"
|
||||||
assert result2["errors"] == {config_flow.CONF_PASSWORD: "auth_failed"}
|
assert result2["errors"] == {config_flow.CONF_PASSWORD: "auth_failed"}
|
||||||
assert result2["description_placeholders"] == {
|
assert result2["description_placeholders"] == {
|
||||||
|
@ -833,7 +833,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.ABORT
|
assert result3["type"] is FlowResultType.ABORT
|
||||||
assert result3["reason"] == "reauth_successful"
|
assert result3["reason"] == "reauth_successful"
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
assert entry.data[config_flow.CONF_USERNAME] == "new-test-username"
|
assert entry.data[config_flow.CONF_USERNAME] == "new-test-username"
|
||||||
|
@ -850,7 +850,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -871,7 +871,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"auto": False},
|
user_input={"auto": False},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -890,7 +890,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
assert entry.data[config_flow.CONF_USERNAME] == USERNAME
|
assert entry.data[config_flow.CONF_USERNAME] == USERNAME
|
||||||
assert entry.data[config_flow.CONF_PASSWORD] == "new_password"
|
assert entry.data[config_flow.CONF_PASSWORD] == "new_password"
|
||||||
|
@ -903,7 +903,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -925,7 +925,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||||
user_input={"auto": False},
|
user_input={"auto": False},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -945,7 +945,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(mock_setup_entry.mock_calls) == 0
|
assert len(mock_setup_entry.mock_calls) == 0
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "configure"
|
assert result["step_id"] == "configure"
|
||||||
assert result["errors"] == {"port": "no_onvif_service"}
|
assert result["errors"] == {"port": "no_onvif_service"}
|
||||||
assert result["description_placeholders"] == {}
|
assert result["description_placeholders"] == {}
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def test_full_user_flow(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result.get("type") == FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -27,6 +27,6 @@ async def test_full_user_flow(
|
||||||
user_input={CONF_ZONE: ENTITY_ID_HOME},
|
user_input={CONF_ZONE: ENTITY_ID_HOME},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||||
assert result2.get("title") == "test home"
|
assert result2.get("title") == "test home"
|
||||||
assert result2.get("data") == {CONF_ZONE: ENTITY_ID_HOME}
|
assert result2.get("data") == {CONF_ZONE: ENTITY_ID_HOME}
|
||||||
|
|
|
@ -30,7 +30,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -50,7 +50,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"api_key": "bla",
|
"api_key": "bla",
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ async def test_options(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert options["type"] == FlowResultType.CREATE_ENTRY
|
assert options["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert options["data"]["prompt"] == "Speak like a pirate"
|
assert options["data"]["prompt"] == "Speak like a pirate"
|
||||||
assert options["data"]["max_tokens"] == 200
|
assert options["data"]["max_tokens"] == 200
|
||||||
assert options["data"][CONF_CHAT_MODEL] == DEFAULT_CHAT_MODEL
|
assert options["data"][CONF_CHAT_MODEL] == DEFAULT_CHAT_MODEL
|
||||||
|
@ -113,5 +113,5 @@ async def test_form_invalid_auth(hass: HomeAssistant, side_effect, error) -> Non
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": error}
|
assert result2["errors"] == {"base": error}
|
||||||
|
|
|
@ -38,7 +38,7 @@ async def test_user_create_entry(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -47,7 +47,7 @@ async def test_user_create_entry(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "USD"
|
assert result["title"] == "USD"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
"api_key": "test-api-key",
|
"api_key": "test-api-key",
|
||||||
|
@ -71,7 +71,7 @@ async def test_form_invalid_auth(
|
||||||
{"api_key": "bad-api-key"},
|
{"api_key": "bad-api-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ async def test_form_cannot_connect(
|
||||||
{"api_key": "test-api-key"},
|
{"api_key": "test-api-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "cannot_connect"}
|
assert result["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ async def test_form_unknown_error(
|
||||||
{"api_key": "test-api-key"},
|
{"api_key": "test-api-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ async def test_already_configured_service(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -131,7 +131,7 @@ async def test_already_configured_service(
|
||||||
{"api_key": "test-api-key"},
|
{"api_key": "test-api-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ async def test_no_currencies(hass: HomeAssistant, currencies: AsyncMock) -> None
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ async def test_currencies_timeout(hass: HomeAssistant, currencies: AsyncMock) ->
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "timeout_connect"
|
assert result["reason"] == "timeout_connect"
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ async def test_latest_rates_timeout(
|
||||||
{"api_key": "test-api-key"},
|
{"api_key": "test-api-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "timeout_connect"}
|
assert result["errors"] == {"base": "timeout_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ async def test_reauth(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context=flow_context, data=mock_config_entry.data
|
DOMAIN, context=flow_context, data=mock_config_entry.data
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
mock_latest_rates_config_flow.side_effect = OpenExchangeRatesAuthError()
|
mock_latest_rates_config_flow.side_effect = OpenExchangeRatesAuthError()
|
||||||
|
@ -222,7 +222,7 @@ async def test_reauth(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
mock_latest_rates_config_flow.side_effect = None
|
mock_latest_rates_config_flow.side_effect = None
|
||||||
|
|
|
@ -18,7 +18,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Name of the device"
|
assert result2["title"] == "Name of the device"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"host": "http://1.1.1.1",
|
"host": "http://1.1.1.1",
|
||||||
|
@ -63,7 +63,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||||
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||||
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||||
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
{"host": "http://1.1.1.1", "device_key": "AfsasdnfkjDD"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,5 +132,5 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Tests for the Openhome config flow module."""
|
"""Tests for the Openhome config flow module."""
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.components.openhome.const import DOMAIN
|
from homeassistant.components.openhome.const import DOMAIN
|
||||||
from homeassistant.components.ssdp import ATTR_UPNP_FRIENDLY_NAME, ATTR_UPNP_UDN
|
from homeassistant.components.ssdp import ATTR_UPNP_FRIENDLY_NAME, ATTR_UPNP_UDN
|
||||||
|
@ -31,7 +30,7 @@ async def test_ssdp(hass: HomeAssistant) -> None:
|
||||||
data=MOCK_DISCOVER,
|
data=MOCK_DISCOVER,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "confirm"
|
assert result["step_id"] == "confirm"
|
||||||
assert result["description_placeholders"] == {CONF_NAME: MOCK_FRIENDLY_NAME}
|
assert result["description_placeholders"] == {CONF_NAME: MOCK_FRIENDLY_NAME}
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ async def test_device_exists(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_SSDP},
|
context={CONF_SOURCE: SOURCE_SSDP},
|
||||||
data=MOCK_DISCOVER,
|
data=MOCK_DISCOVER,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ async def test_missing_udn(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_SSDP},
|
context={CONF_SOURCE: SOURCE_SSDP},
|
||||||
data=broken_discovery,
|
data=broken_discovery,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "incomplete_discovery"
|
assert result["reason"] == "incomplete_discovery"
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ async def test_missing_ssdp_location(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_SSDP},
|
context={CONF_SOURCE: SOURCE_SSDP},
|
||||||
data=broken_discovery,
|
data=broken_discovery,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "incomplete_discovery"
|
assert result["reason"] == "incomplete_discovery"
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +109,7 @@ async def test_host_updated(hass: HomeAssistant) -> None:
|
||||||
context={CONF_SOURCE: SOURCE_SSDP},
|
context={CONF_SOURCE: SOURCE_SSDP},
|
||||||
data=MOCK_DISCOVER,
|
data=MOCK_DISCOVER,
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
assert entry.data[CONF_HOST] == MOCK_SSDP_LOCATION
|
assert entry.data[CONF_HOST] == MOCK_SSDP_LOCATION
|
||||||
|
|
|
@ -6,7 +6,6 @@ from unittest.mock import AsyncMock
|
||||||
import pytest
|
import pytest
|
||||||
from python_opensky.exceptions import OpenSkyUnauthenticatedError
|
from python_opensky.exceptions import OpenSkyUnauthenticatedError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.opensky.const import (
|
from homeassistant.components.opensky.const import (
|
||||||
CONF_ALTITUDE,
|
CONF_ALTITUDE,
|
||||||
CONF_CONTRIBUTING_USER,
|
CONF_CONTRIBUTING_USER,
|
||||||
|
@ -43,7 +42,7 @@ async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||||
CONF_ALTITUDE: 0,
|
CONF_ALTITUDE: 0,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == "OpenSky"
|
assert result["title"] == "OpenSky"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_LATITUDE: 0.0,
|
CONF_LATITUDE: 0.0,
|
||||||
|
@ -89,7 +88,7 @@ async def test_options_flow_failures(
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -98,7 +97,7 @@ async def test_options_flow_failures(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert result["errors"]["base"] == error
|
assert result["errors"]["base"] == error
|
||||||
opensky_client.authenticate.side_effect = None
|
opensky_client.authenticate.side_effect = None
|
||||||
|
@ -113,7 +112,7 @@ async def test_options_flow_failures(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_RADIUS: 10000,
|
CONF_RADIUS: 10000,
|
||||||
CONF_USERNAME: "homeassistant",
|
CONF_USERNAME: "homeassistant",
|
||||||
|
@ -143,7 +142,7 @@ async def test_options_flow(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_RADIUS: 10000,
|
CONF_RADIUS: 10000,
|
||||||
CONF_USERNAME: "homeassistant",
|
CONF_USERNAME: "homeassistant",
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||||
from pyotgw.vars import OTGW, OTGW_ABOUT
|
from pyotgw.vars import OTGW, OTGW_ABOUT
|
||||||
from serial import SerialException
|
from serial import SerialException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.opentherm_gw.const import (
|
from homeassistant.components.opentherm_gw.const import (
|
||||||
CONF_FLOOR_TEMP,
|
CONF_FLOOR_TEMP,
|
||||||
CONF_PRECISION,
|
CONF_PRECISION,
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
||||||
PRECISION_TENTHS,
|
PRECISION_TENTHS,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ async def test_options_migration(hass: HomeAssistant) -> None:
|
||||||
entry.entry_id, context={"source": config_entries.SOURCE_USER}, data=None
|
entry.entry_id, context={"source": config_entries.SOURCE_USER}, data=None
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -249,7 +250,7 @@ async def test_options_migration(hass: HomeAssistant) -> None:
|
||||||
user_input={},
|
user_input={},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_READ_PRECISION] == PRECISION_TENTHS
|
assert result["data"][CONF_READ_PRECISION] == PRECISION_TENTHS
|
||||||
assert result["data"][CONF_SET_PRECISION] == PRECISION_TENTHS
|
assert result["data"][CONF_SET_PRECISION] == PRECISION_TENTHS
|
||||||
assert result["data"][CONF_FLOOR_TEMP] is True
|
assert result["data"][CONF_FLOOR_TEMP] is True
|
||||||
|
@ -281,7 +282,7 @@ async def test_options_form(hass: HomeAssistant) -> None:
|
||||||
result = await hass.config_entries.options.async_init(
|
result = await hass.config_entries.options.async_init(
|
||||||
entry.entry_id, context={"source": "test"}, data=None
|
entry.entry_id, context={"source": "test"}, data=None
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
|
@ -294,7 +295,7 @@ async def test_options_form(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_READ_PRECISION] == PRECISION_HALVES
|
assert result["data"][CONF_READ_PRECISION] == PRECISION_HALVES
|
||||||
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
||||||
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is True
|
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is True
|
||||||
|
@ -308,7 +309,7 @@ async def test_options_form(hass: HomeAssistant) -> None:
|
||||||
result["flow_id"], user_input={CONF_READ_PRECISION: 0}
|
result["flow_id"], user_input={CONF_READ_PRECISION: 0}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_READ_PRECISION] == 0.0
|
assert result["data"][CONF_READ_PRECISION] == 0.0
|
||||||
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
||||||
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is True
|
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is True
|
||||||
|
@ -328,7 +329,7 @@ async def test_options_form(hass: HomeAssistant) -> None:
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["data"][CONF_READ_PRECISION] == PRECISION_TENTHS
|
assert result["data"][CONF_READ_PRECISION] == PRECISION_TENTHS
|
||||||
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
assert result["data"][CONF_SET_PRECISION] == PRECISION_HALVES
|
||||||
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is False
|
assert result["data"][CONF_TEMPORARY_OVRD_MODE] is False
|
||||||
|
|
|
@ -6,7 +6,6 @@ from pyopenuv.errors import InvalidApiKeyError
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.openuv import CONF_FROM_WINDOW, CONF_TO_WINDOW, DOMAIN
|
from homeassistant.components.openuv import CONF_FROM_WINDOW, CONF_TO_WINDOW, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
|
@ -16,6 +15,7 @@ from homeassistant.const import (
|
||||||
CONF_LONGITUDE,
|
CONF_LONGITUDE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .conftest import TEST_API_KEY, TEST_ELEVATION, TEST_LATITUDE, TEST_LONGITUDE
|
from .conftest import TEST_API_KEY, TEST_ELEVATION, TEST_LATITUDE, TEST_LONGITUDE
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ async def test_create_entry(hass: HomeAssistant, client, config, mock_pyopenuv)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
# Test an error occurring:
|
# Test an error occurring:
|
||||||
|
@ -35,7 +35,7 @@ async def test_create_entry(hass: HomeAssistant, client, config, mock_pyopenuv)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=config
|
result["flow_id"], user_input=config
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {CONF_API_KEY: "invalid_api_key"}
|
assert result["errors"] == {CONF_API_KEY: "invalid_api_key"}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ async def test_create_entry(hass: HomeAssistant, client, config, mock_pyopenuv)
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input=config
|
result["flow_id"], user_input=config
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == f"{TEST_LATITUDE}, {TEST_LONGITUDE}"
|
assert result["title"] == f"{TEST_LATITUDE}, {TEST_LONGITUDE}"
|
||||||
assert result["data"] == {
|
assert result["data"] == {
|
||||||
CONF_API_KEY: TEST_API_KEY,
|
CONF_API_KEY: TEST_API_KEY,
|
||||||
|
@ -60,7 +60,7 @@ async def test_duplicate_error(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=config
|
DOMAIN, context={"source": SOURCE_USER}, data=config
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ async def test_options_flow(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test config flow options."""
|
"""Test config flow options."""
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
def get_schema_marker(data_schema: vol.Schema, key: str) -> vol.Marker:
|
def get_schema_marker(data_schema: vol.Schema, key: str) -> vol.Marker:
|
||||||
|
@ -89,12 +89,12 @@ async def test_options_flow(
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_FROM_WINDOW: 3.5, CONF_TO_WINDOW: 2.0}
|
result["flow_id"], user_input={CONF_FROM_WINDOW: 3.5, CONF_TO_WINDOW: 2.0}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {CONF_FROM_WINDOW: 3.5, CONF_TO_WINDOW: 2.0}
|
assert config_entry.options == {CONF_FROM_WINDOW: 3.5, CONF_TO_WINDOW: 2.0}
|
||||||
|
|
||||||
# Subsequent schema uses previous input for suggested values:
|
# Subsequent schema uses previous input for suggested values:
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
assert get_schema_marker(result["data_schema"], CONF_FROM_WINDOW).description == {
|
assert get_schema_marker(result["data_schema"], CONF_FROM_WINDOW).description == {
|
||||||
"suggested_value": 3.5
|
"suggested_value": 3.5
|
||||||
|
@ -114,12 +114,12 @@ async def test_step_reauth(
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_API_KEY: "new_api_key"}
|
result["flow_id"], user_input={CONF_API_KEY: "new_api_key"}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
assert len(hass.config_entries.async_entries()) == 1
|
assert len(hass.config_entries.async_entries()) == 1
|
||||||
|
|
|
@ -4,7 +4,6 @@ from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from pyowm.commons.exceptions import APIRequestError, UnauthorizedError
|
from pyowm.commons.exceptions import APIRequestError, UnauthorizedError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
|
||||||
from homeassistant.components.openweathermap.const import (
|
from homeassistant.components.openweathermap.const import (
|
||||||
DEFAULT_FORECAST_MODE,
|
DEFAULT_FORECAST_MODE,
|
||||||
DEFAULT_LANGUAGE,
|
DEFAULT_LANGUAGE,
|
||||||
|
@ -20,6 +19,7 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert entry.state == ConfigEntryState.NOT_LOADED
|
assert entry.state == ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result["title"] == CONFIG[CONF_NAME]
|
assert result["title"] == CONFIG[CONF_NAME]
|
||||||
assert result["data"][CONF_LATITUDE] == CONFIG[CONF_LATITUDE]
|
assert result["data"][CONF_LATITUDE] == CONFIG[CONF_LATITUDE]
|
||||||
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]
|
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]
|
||||||
|
@ -92,14 +92,14 @@ async def test_form_options(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_MODE: "daily"}
|
result["flow_id"], user_input={CONF_MODE: "daily"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_MODE: "daily",
|
CONF_MODE: "daily",
|
||||||
CONF_LANGUAGE: DEFAULT_LANGUAGE,
|
CONF_LANGUAGE: DEFAULT_LANGUAGE,
|
||||||
|
@ -111,14 +111,14 @@ async def test_form_options(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
|
||||||
result = await hass.config_entries.options.async_configure(
|
result = await hass.config_entries.options.async_configure(
|
||||||
result["flow_id"], user_input={CONF_MODE: "onecall_daily"}
|
result["flow_id"], user_input={CONF_MODE: "onecall_daily"}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert config_entry.options == {
|
assert config_entry.options == {
|
||||||
CONF_MODE: "onecall_daily",
|
CONF_MODE: "onecall_daily",
|
||||||
CONF_LANGUAGE: DEFAULT_LANGUAGE,
|
CONF_LANGUAGE: DEFAULT_LANGUAGE,
|
||||||
|
|
|
@ -42,7 +42,7 @@ async def test_form(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -58,7 +58,7 @@ async def test_form(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result2["title"] == "Pacific Gas and Electric Company (PG&E) (test-username)"
|
assert result2["title"] == "Pacific Gas and Electric Company (PG&E) (test-username)"
|
||||||
assert result2["data"] == {
|
assert result2["data"] == {
|
||||||
"utility": "Pacific Gas and Electric Company (PG&E)",
|
"utility": "Pacific Gas and Electric Company (PG&E)",
|
||||||
|
@ -76,7 +76,7 @@ async def test_form_with_mfa(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -87,7 +87,7 @@ async def test_form_with_mfa(
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert not result2["errors"]
|
assert not result2["errors"]
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -100,7 +100,7 @@ async def test_form_with_mfa(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result3["title"] == "Consolidated Edison (ConEd) (test-username)"
|
assert result3["title"] == "Consolidated Edison (ConEd) (test-username)"
|
||||||
assert result3["data"] == {
|
assert result3["data"] == {
|
||||||
"utility": "Consolidated Edison (ConEd)",
|
"utility": "Consolidated Edison (ConEd)",
|
||||||
|
@ -119,7 +119,7 @@ async def test_form_with_mfa_bad_secret(
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["type"] == FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -130,7 +130,7 @@ async def test_form_with_mfa_bad_secret(
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert not result2["errors"]
|
assert not result2["errors"]
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -144,7 +144,7 @@ async def test_form_with_mfa_bad_secret(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result3["type"] == FlowResultType.FORM
|
assert result3["type"] is FlowResultType.FORM
|
||||||
assert result3["errors"] == {
|
assert result3["errors"] == {
|
||||||
"base": "invalid_auth",
|
"base": "invalid_auth",
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ async def test_form_with_mfa_bad_secret(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert result4["title"] == "Consolidated Edison (ConEd) (test-username)"
|
assert result4["title"] == "Consolidated Edison (ConEd) (test-username)"
|
||||||
assert result4["data"] == {
|
assert result4["data"] == {
|
||||||
"utility": "Consolidated Edison (ConEd)",
|
"utility": "Consolidated Edison (ConEd)",
|
||||||
|
@ -201,7 +201,7 @@ async def test_form_exceptions(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] is FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": expected_error}
|
assert result2["errors"] == {"base": expected_error}
|
||||||
assert mock_login.call_count == 1
|
assert mock_login.call_count == 1
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ async def test_form_already_configured(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
assert mock_login.call_count == 0
|
assert mock_login.call_count == 0
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ async def test_form_not_already_configured(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||||
assert (
|
assert (
|
||||||
result2["title"] == "Pacific Gas and Electric Company (PG&E) (test-username2)"
|
result2["title"] == "Pacific Gas and Electric Company (PG&E) (test-username2)"
|
||||||
)
|
)
|
||||||
|
@ -297,7 +297,7 @@ async def test_form_valid_reauth(
|
||||||
{"username": "test-username", "password": "test-password2"},
|
{"username": "test-username", "password": "test-password2"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -347,7 +347,7 @@ async def test_form_valid_reauth_with_mfa(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue