mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Switch a few recent merges to use FlowResultType (#76416)
This commit is contained in:
parent
714d46b153
commit
33b194e48d
@ -15,11 +15,7 @@ from homeassistant.components import zeroconf
|
|||||||
from homeassistant.components.homekit_controller import config_flow
|
from homeassistant.components.homekit_controller import config_flow
|
||||||
from homeassistant.components.homekit_controller.const import KNOWN_DEVICES
|
from homeassistant.components.homekit_controller.const import KNOWN_DEVICES
|
||||||
from homeassistant.components.homekit_controller.storage import async_get_entity_storage
|
from homeassistant.components.homekit_controller.storage import async_get_entity_storage
|
||||||
from homeassistant.data_entry_flow import (
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
RESULT_TYPE_ABORT,
|
|
||||||
RESULT_TYPE_FORM,
|
|
||||||
FlowResultType,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
from homeassistant.helpers.service_info.bluetooth import BluetoothServiceInfo
|
from homeassistant.helpers.service_info.bluetooth import BluetoothServiceInfo
|
||||||
|
|
||||||
@ -1017,7 +1013,7 @@ async def test_discovery_no_bluetooth_support(hass, controller):
|
|||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=HK_BLUETOOTH_SERVICE_INFO_NOT_DISCOVERED,
|
data=HK_BLUETOOTH_SERVICE_INFO_NOT_DISCOVERED,
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == FlowResultType.ABORT
|
||||||
assert result["reason"] == "ignored_model"
|
assert result["reason"] == "ignored_model"
|
||||||
|
|
||||||
|
|
||||||
@ -1032,7 +1028,7 @@ async def test_bluetooth_not_homekit(hass, controller):
|
|||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=NOT_HK_BLUETOOTH_SERVICE_INFO,
|
data=NOT_HK_BLUETOOTH_SERVICE_INFO,
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == FlowResultType.ABORT
|
||||||
assert result["reason"] == "ignored_model"
|
assert result["reason"] == "ignored_model"
|
||||||
|
|
||||||
|
|
||||||
@ -1047,7 +1043,7 @@ async def test_bluetooth_valid_device_no_discovery(hass, controller):
|
|||||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||||
data=HK_BLUETOOTH_SERVICE_INFO_NOT_DISCOVERED,
|
data=HK_BLUETOOTH_SERVICE_INFO_NOT_DISCOVERED,
|
||||||
)
|
)
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == FlowResultType.ABORT
|
||||||
assert result["reason"] == "accessory_not_found_error"
|
assert result["reason"] == "accessory_not_found_error"
|
||||||
|
|
||||||
|
|
||||||
@ -1065,7 +1061,7 @@ async def test_bluetooth_valid_device_discovery_paired(hass, controller):
|
|||||||
data=HK_BLUETOOTH_SERVICE_INFO_DISCOVERED_PAIRED,
|
data=HK_BLUETOOTH_SERVICE_INFO_DISCOVERED_PAIRED,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_paired"
|
assert result["reason"] == "already_paired"
|
||||||
|
|
||||||
|
|
||||||
@ -1084,7 +1080,7 @@ async def test_bluetooth_valid_device_discovery_unpaired(hass, controller):
|
|||||||
data=HK_BLUETOOTH_SERVICE_INFO_DISCOVERED_UNPAIRED,
|
data=HK_BLUETOOTH_SERVICE_INFO_DISCOVERED_UNPAIRED,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["step_id"] == "pair"
|
assert result["step_id"] == "pair"
|
||||||
assert storage.get_map("00:00:00:00:00:00") is None
|
assert storage.get_map("00:00:00:00:00:00") is None
|
||||||
|
|
||||||
@ -1095,7 +1091,7 @@ async def test_bluetooth_valid_device_discovery_unpaired(hass, controller):
|
|||||||
}
|
}
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
result3 = await hass.config_entries.flow.async_configure(
|
result3 = await hass.config_entries.flow.async_configure(
|
||||||
result2["flow_id"], user_input={"pairing_code": "111-22-333"}
|
result2["flow_id"], user_input={"pairing_code": "111-22-333"}
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ from lacrosse_view import Location, LoginError
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.lacrosse_view.const import DOMAIN
|
from homeassistant.components.lacrosse_view.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
|
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, FlowResultType
|
||||||
|
|
||||||
|
|
||||||
async def test_form(hass: HomeAssistant) -> None:
|
async def test_form(hass: HomeAssistant) -> None:
|
||||||
@ -14,7 +14,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"] == RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with patch("lacrosse_view.LaCrosse.login", return_value=True,), patch(
|
with patch("lacrosse_view.LaCrosse.login", return_value=True,), patch(
|
||||||
@ -30,7 +30,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["step_id"] == "location"
|
assert result2["step_id"] == "location"
|
||||||
assert result2["errors"] is None
|
assert result2["errors"] is None
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ async def test_form_auth_false(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ async def test_form_login_first(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_auth"}
|
assert result2["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ async def test_form_no_locations(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "no_locations"}
|
assert result2["errors"] == {"base": "no_locations"}
|
||||||
|
|
||||||
|
|
||||||
@ -159,5 +159,5 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == RESULT_TYPE_FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "unknown"}
|
assert result2["errors"] == {"base": "unknown"}
|
||||||
|
@ -10,7 +10,7 @@ from homeassistant.components.lifx import DOMAIN
|
|||||||
from homeassistant.components.lifx.const import CONF_SERIAL
|
from homeassistant.components.lifx.const import CONF_SERIAL
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_HOST
|
from homeassistant.const import CONF_DEVICE, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import RESULT_TYPE_ABORT, RESULT_TYPE_FORM
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
DEFAULT_ENTRY_TITLE,
|
DEFAULT_ENTRY_TITLE,
|
||||||
@ -332,7 +332,7 @@ async def test_discovered_by_discovery_and_dhcp(hass):
|
|||||||
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"] == RESULT_TYPE_FORM
|
assert result["type"] == 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():
|
||||||
@ -344,7 +344,7 @@ async def test_discovered_by_discovery_and_dhcp(hass):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result2["type"] == RESULT_TYPE_ABORT
|
assert result2["type"] == 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():
|
||||||
@ -356,7 +356,7 @@ async def test_discovered_by_discovery_and_dhcp(hass):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == RESULT_TYPE_ABORT
|
assert result3["type"] == FlowResultType.ABORT
|
||||||
assert result3["reason"] == "already_in_progress"
|
assert result3["reason"] == "already_in_progress"
|
||||||
|
|
||||||
with _patch_discovery(no_device=True), _patch_config_flow_try_connect(
|
with _patch_discovery(no_device=True), _patch_config_flow_try_connect(
|
||||||
@ -370,7 +370,7 @@ async def test_discovered_by_discovery_and_dhcp(hass):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result3["type"] == RESULT_TYPE_ABORT
|
assert result3["type"] == FlowResultType.ABORT
|
||||||
assert result3["reason"] == "cannot_connect"
|
assert result3["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ async def test_discovered_by_dhcp_or_discovery(hass, source, data):
|
|||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert result["type"] == RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
with _patch_discovery(), _patch_config_flow_try_connect(), patch(
|
with _patch_discovery(), _patch_config_flow_try_connect(), patch(
|
||||||
@ -462,7 +462,7 @@ async def test_discovered_by_dhcp_or_discovery_failed_to_get_device(hass, source
|
|||||||
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"] == RESULT_TYPE_ABORT
|
assert result["type"] == FlowResultType.ABORT
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
|
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ async def test_discovered_by_dhcp_updates_ip(hass):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["type"] == RESULT_TYPE_ABORT
|
assert result["type"] == 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
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ from homeassistant.components.simplisafe import DOMAIN
|
|||||||
from homeassistant.components.simplisafe.config_flow import CONF_AUTH_CODE
|
from homeassistant.components.simplisafe.config_flow import CONF_AUTH_CODE
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||||
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_USERNAME
|
||||||
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
VALID_AUTH_CODE = "code12345123451234512345123451234512345123451"
|
VALID_AUTH_CODE = "code12345123451234512345123451234512345123451"
|
||||||
|
|
||||||
@ -23,12 +24,12 @@ async def test_duplicate_error(config_entry, hass, setup_simplisafe):
|
|||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
@ -38,12 +39,12 @@ async def test_invalid_auth_code_length(hass):
|
|||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_AUTH_CODE: "too_short_code"}
|
result["flow_id"], user_input={CONF_AUTH_CODE: "too_short_code"}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth_code_length"}
|
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth_code_length"}
|
||||||
|
|
||||||
|
|
||||||
@ -57,13 +58,13 @@ async def test_invalid_credentials(hass):
|
|||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == 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={CONF_AUTH_CODE: VALID_AUTH_CODE},
|
user_input={CONF_AUTH_CODE: VALID_AUTH_CODE},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth"}
|
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ async def test_options_flow(config_entry, hass):
|
|||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
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.RESULT_TYPE_FORM
|
assert result["type"] == 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(
|
||||||
@ -101,7 +102,7 @@ async def test_step_reauth(config_entry, hass, setup_simplisafe):
|
|||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.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
|
||||||
@ -125,7 +126,7 @@ async def test_step_reauth_wrong_account(config_entry, hass, setup_simplisafe):
|
|||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||||
assert result["reason"] == "wrong_account"
|
assert result["reason"] == "wrong_account"
|
||||||
|
|
||||||
|
|
||||||
@ -177,10 +178,10 @@ async def test_unknown_error(hass, setup_simplisafe):
|
|||||||
DOMAIN, context={"source": SOURCE_USER}
|
DOMAIN, context={"source": SOURCE_USER}
|
||||||
)
|
)
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "unknown"}
|
assert result["errors"] == {"base": "unknown"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user