Use is in enum comparison in config flow tests P-T (#114675)

This commit is contained in:
Joost Lekkerkerker
2024-04-02 23:21:50 +02:00
committed by GitHub
parent 5d500cb74b
commit ee66f6ec8c
164 changed files with 1919 additions and 1890 deletions

View File

@@ -46,7 +46,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=WOHAND_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
with patch_async_setup_entry() as mock_setup_entry:
@@ -56,7 +56,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Bot EEFF"
assert result["data"] == {
CONF_ADDRESS: "AA:BB:CC:DD:EE:FF",
@@ -73,7 +73,7 @@ async def test_bluetooth_discovery_requires_password(hass: HomeAssistant) -> Non
context={"source": SOURCE_BLUETOOTH},
data=WOHAND_ENCRYPTED_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "password"
with patch_async_setup_entry() as mock_setup_entry:
@@ -83,7 +83,7 @@ async def test_bluetooth_discovery_requires_password(hass: HomeAssistant) -> Non
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Bot 923B"
assert result["data"] == {
CONF_ADDRESS: "798A8547-2A3D-C609-55FF-73FA824B923B",
@@ -101,14 +101,14 @@ async def test_bluetooth_discovery_lock_key(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=WOLOCK_SERVICE_INFO,
)
assert result["type"] == FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "lock_choose_method"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"next_step_id": "lock_key"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_key"
assert result["errors"] == {}
@@ -125,7 +125,7 @@ async def test_bluetooth_discovery_lock_key(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_key"
assert result["errors"] == {"base": "encryption_key_invalid"}
@@ -145,7 +145,7 @@ async def test_bluetooth_discovery_lock_key(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Lock EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -175,7 +175,7 @@ async def test_bluetooth_discovery_already_setup(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=WOHAND_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@@ -186,7 +186,7 @@ async def test_async_step_bluetooth_not_switchbot(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=NOT_SWITCHBOT_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported"
@@ -197,7 +197,7 @@ async def test_async_step_bluetooth_not_connectable(hass: HomeAssistant) -> None
context={"source": SOURCE_BLUETOOTH},
data=WOHAND_SERVICE_INFO_NOT_CONNECTABLE,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported"
@@ -211,7 +211,7 @@ async def test_user_setup_wohand(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] is None
@@ -222,7 +222,7 @@ async def test_user_setup_wohand(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Bot EEFF"
assert result["data"] == {
CONF_ADDRESS: "AA:BB:CC:DD:EE:FF",
@@ -252,7 +252,7 @@ async def test_user_setup_wohand_already_configured(hass: HomeAssistant) -> None
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@@ -266,7 +266,7 @@ async def test_user_setup_wocurtain(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] is None
@@ -277,7 +277,7 @@ async def test_user_setup_wocurtain(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Curtain EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -302,7 +302,7 @@ async def test_user_setup_wocurtain_or_bot(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@@ -313,7 +313,7 @@ async def test_user_setup_wocurtain_or_bot(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Curtain EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -337,7 +337,7 @@ async def test_user_setup_wocurtain_or_bot_with_password(hass: HomeAssistant) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@@ -345,7 +345,7 @@ async def test_user_setup_wocurtain_or_bot_with_password(hass: HomeAssistant) ->
result["flow_id"],
{CONF_ADDRESS: "798A8547-2A3D-C609-55FF-73FA824B923B"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "password"
assert result2["errors"] is None
@@ -356,7 +356,7 @@ async def test_user_setup_wocurtain_or_bot_with_password(hass: HomeAssistant) ->
)
await hass.async_block_till_done()
assert result3["type"] == FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "Bot 923B"
assert result3["data"] == {
CONF_ADDRESS: "798A8547-2A3D-C609-55FF-73FA824B923B",
@@ -377,7 +377,7 @@ async def test_user_setup_single_bot_with_password(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "password"
assert result["errors"] is None
@@ -388,7 +388,7 @@ async def test_user_setup_single_bot_with_password(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Bot 923B"
assert result2["data"] == {
CONF_ADDRESS: "798A8547-2A3D-C609-55FF-73FA824B923B",
@@ -409,14 +409,14 @@ async def test_user_setup_wolock_key(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "lock_choose_method"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"next_step_id": "lock_key"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_key"
assert result["errors"] == {}
@@ -433,7 +433,7 @@ async def test_user_setup_wolock_key(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_key"
assert result["errors"] == {"base": "encryption_key_invalid"}
@@ -453,7 +453,7 @@ async def test_user_setup_wolock_key(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Lock EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -475,14 +475,14 @@ async def test_user_setup_wolock_auth(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "lock_choose_method"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"next_step_id": "lock_auth"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_auth"
assert result["errors"] == {}
@@ -498,7 +498,7 @@ async def test_user_setup_wolock_auth(hass: HomeAssistant) -> None:
},
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_auth"
assert result["errors"] == {"base": "auth_failed"}
assert "error from api" in result["description_placeholders"]["error_detail"]
@@ -526,7 +526,7 @@ async def test_user_setup_wolock_auth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Lock EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -548,14 +548,14 @@ async def test_user_setup_wolock_auth_switchbot_api_down(hass: HomeAssistant) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "lock_choose_method"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"next_step_id": "lock_auth"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_auth"
assert result["errors"] == {}
@@ -571,7 +571,7 @@ async def test_user_setup_wolock_auth_switchbot_api_down(hass: HomeAssistant) ->
},
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@@ -588,7 +588,7 @@ async def test_user_setup_wolock_or_bot(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@@ -597,14 +597,14 @@ async def test_user_setup_wolock_or_bot(hass: HomeAssistant) -> None:
USER_INPUT,
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "lock_choose_method"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"next_step_id": "lock_key"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "lock_key"
assert result["errors"] == {}
@@ -624,7 +624,7 @@ async def test_user_setup_wolock_or_bot(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Lock EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -645,7 +645,7 @@ async def test_user_setup_wosensor(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] is None
@@ -656,7 +656,7 @@ async def test_user_setup_wosensor(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Meter EEFF"
assert result["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -675,7 +675,7 @@ async def test_user_no_devices(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@@ -688,7 +688,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": SOURCE_BLUETOOTH},
data=WOCURTAIN_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
with patch(
@@ -699,7 +699,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
DOMAIN,
context={"source": SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
@@ -707,7 +707,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
user_input={},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Curtain EEFF"
assert result2["data"] == {
CONF_ADDRESS: "aa:bb:cc:dd:ee:ff",
@@ -740,7 +740,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
entry = await init_integration(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] is None
@@ -752,7 +752,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_RETRY_COUNT] == 3
assert len(mock_setup_entry.mock_calls) == 2
@@ -763,7 +763,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
entry = await init_integration(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] is None
@@ -775,7 +775,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_RETRY_COUNT] == 6
assert len(mock_setup_entry.mock_calls) == 1