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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
164 changed files with 1919 additions and 1890 deletions

View file

@ -17,7 +17,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
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"
with ( with (
@ -33,7 +33,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
user_input={CONF_HOST: "example.com"}, user_input={CONF_HOST: "example.com"},
) )
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "P1 Monitor" assert result2.get("title") == "P1 Monitor"
assert result2.get("data") == {CONF_HOST: "example.com"} assert result2.get("data") == {CONF_HOST: "example.com"}
@ -53,5 +53,5 @@ async def test_api_error(hass: HomeAssistant) -> None:
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("errors") == {"base": "cannot_connect"} assert result.get("errors") == {"base": "cannot_connect"}

View file

@ -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
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -33,7 +33,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"] == "Philadelphia Outage Count" assert result2["title"] == "Philadelphia Outage Count"
assert result2["data"] == { assert result2["data"] == {
"county": "PHILADELPHIA", "county": "PHILADELPHIA",
@ -46,7 +46,7 @@ async def test_invalid_county(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"
with ( with (
@ -70,7 +70,7 @@ async def test_meter_value_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"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -82,7 +82,7 @@ async def test_meter_value_error(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"] == {"phone_number": "invalid_phone_number"} assert result["errors"] == {"phone_number": "invalid_phone_number"}
@ -92,7 +92,7 @@ async def test_incompatible_meter_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"
with patch("peco.PecoOutageApi.meter_check", side_effect=IncompatibleMeterError()): with patch("peco.PecoOutageApi.meter_check", side_effect=IncompatibleMeterError()):
@ -105,7 +105,7 @@ async def test_incompatible_meter_error(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"] == "incompatible_meter" assert result["reason"] == "incompatible_meter"
@ -114,7 +114,7 @@ async def test_unresponsive_meter_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"
with patch("peco.PecoOutageApi.meter_check", side_effect=UnresponsiveMeterError()): with patch("peco.PecoOutageApi.meter_check", side_effect=UnresponsiveMeterError()):
@ -127,7 +127,7 @@ async def test_unresponsive_meter_error(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"] == {"phone_number": "unresponsive_meter"} assert result["errors"] == {"phone_number": "unresponsive_meter"}
@ -137,7 +137,7 @@ async def test_meter_http_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"
with patch("peco.PecoOutageApi.meter_check", side_effect=HttpError): with patch("peco.PecoOutageApi.meter_check", side_effect=HttpError):
@ -150,7 +150,7 @@ async def test_meter_http_error(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"] == {"phone_number": "http_error"} assert result["errors"] == {"phone_number": "http_error"}
@ -160,7 +160,7 @@ async def test_smart_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"
with patch("peco.PecoOutageApi.meter_check", return_value=True): with patch("peco.PecoOutageApi.meter_check", return_value=True):
@ -173,7 +173,7 @@ async def test_smart_meter(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"] == "Philadelphia - 1234567890" assert result["title"] == "Philadelphia - 1234567890"
assert result["data"]["phone_number"] == "1234567890" assert result["data"]["phone_number"] == "1234567890"
assert result["context"]["unique_id"] == "PHILADELPHIA-1234567890" assert result["context"]["unique_id"] == "PHILADELPHIA-1234567890"

View file

@ -33,7 +33,7 @@ async def test_user(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"] == "user" assert result["step_id"] == "user"
with ( with (
@ -48,13 +48,13 @@ async def test_user(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_station" assert result["step_id"] == "select_station"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP2 result["flow_id"], user_input=MOCK_USER_DATA_STEP2
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae" assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae"
assert result["title"] == "DRESDEN ELBE" assert result["title"] == "DRESDEN ELBE"
@ -75,7 +75,7 @@ async def test_user_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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
with patch( with patch(
@ -85,13 +85,13 @@ async def test_user_already_configured(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_station" assert result["step_id"] == "select_station"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP2 result["flow_id"], user_input=MOCK_USER_DATA_STEP2
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -100,7 +100,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": 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 (
@ -116,7 +116,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
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"
@ -125,13 +125,13 @@ async def test_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_station" assert result["step_id"] == "select_station"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP2 result["flow_id"], user_input=MOCK_USER_DATA_STEP2
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae" assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae"
assert result["title"] == "DRESDEN ELBE" assert result["title"] == "DRESDEN ELBE"
@ -145,7 +145,7 @@ async def test_user_no_stations(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"] == "user" assert result["step_id"] == "user"
with ( with (
@ -161,7 +161,7 @@ async def test_user_no_stations(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"][CONF_RADIUS] == "no_stations" assert result["errors"][CONF_RADIUS] == "no_stations"
@ -170,13 +170,13 @@ async def test_user_no_stations(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP1 result["flow_id"], user_input=MOCK_USER_DATA_STEP1
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_station" assert result["step_id"] == "select_station"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA_STEP2 result["flow_id"], user_input=MOCK_USER_DATA_STEP2
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae" assert result["data"][CONF_STATION] == "70272185-xxxx-xxxx-xxxx-43bea330dcae"
assert result["title"] == "DRESDEN ELBE" assert result["title"] == "DRESDEN ELBE"

View file

@ -46,7 +46,7 @@ async def test_sucessful_config_flow(hass: HomeAssistant, my_permobil: Mock) ->
data={CONF_EMAIL: MOCK_EMAIL}, data={CONF_EMAIL: MOCK_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"] == {} assert result["errors"] == {}
@ -56,7 +56,7 @@ async def test_sucessful_config_flow(hass: HomeAssistant, my_permobil: Mock) ->
user_input={CONF_REGION: MOCK_REGION_NAME}, user_input={CONF_REGION: MOCK_REGION_NAME},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"] == {} assert result["errors"] == {}
# request region code # request region code
@ -65,7 +65,7 @@ async def test_sucessful_config_flow(hass: HomeAssistant, my_permobil: Mock) ->
user_input={CONF_CODE: MOCK_CODE}, user_input={CONF_CODE: MOCK_CODE},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == VALID_DATA assert result["data"] == VALID_DATA
@ -89,7 +89,7 @@ async def test_config_flow_incorrect_code(
data={CONF_EMAIL: MOCK_EMAIL}, data={CONF_EMAIL: MOCK_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"] == {} assert result["errors"] == {}
@ -99,7 +99,7 @@ async def test_config_flow_incorrect_code(
user_input={CONF_REGION: MOCK_REGION_NAME}, user_input={CONF_REGION: MOCK_REGION_NAME},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"] == {} assert result["errors"] == {}
@ -109,7 +109,7 @@ async def test_config_flow_incorrect_code(
result["flow_id"], result["flow_id"],
user_input={CONF_CODE: MOCK_CODE}, user_input={CONF_CODE: MOCK_CODE},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"]["base"] == "invalid_code" assert result["errors"]["base"] == "invalid_code"
@ -134,7 +134,7 @@ async def test_config_flow_unsigned_eula(
data={CONF_EMAIL: MOCK_EMAIL}, data={CONF_EMAIL: MOCK_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"] == {} assert result["errors"] == {}
@ -144,7 +144,7 @@ async def test_config_flow_unsigned_eula(
user_input={CONF_REGION: MOCK_REGION_NAME}, user_input={CONF_REGION: MOCK_REGION_NAME},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"] == {} assert result["errors"] == {}
@ -154,7 +154,7 @@ async def test_config_flow_unsigned_eula(
result["flow_id"], result["flow_id"],
user_input={CONF_CODE: MOCK_CODE}, user_input={CONF_CODE: MOCK_CODE},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"]["base"] == "unsigned_eula" assert result["errors"]["base"] == "unsigned_eula"
@ -170,7 +170,7 @@ async def test_config_flow_unsigned_eula(
) )
# Now the method should not raise an exception, and you can proceed with your assertions # Now the method should not raise an exception, and you can proceed with your assertions
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == VALID_DATA assert result["data"] == VALID_DATA
@ -195,7 +195,7 @@ async def test_config_flow_incorrect_region(
data={CONF_EMAIL: MOCK_EMAIL}, data={CONF_EMAIL: MOCK_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"] == {} assert result["errors"] == {}
@ -206,7 +206,7 @@ async def test_config_flow_incorrect_region(
user_input={CONF_REGION: MOCK_REGION_NAME}, user_input={CONF_REGION: MOCK_REGION_NAME},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"]["base"] == "code_request_error" assert result["errors"]["base"] == "code_request_error"
@ -232,7 +232,7 @@ async def test_config_flow_region_request_error(
data={CONF_EMAIL: MOCK_EMAIL}, data={CONF_EMAIL: MOCK_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "region" assert result["step_id"] == "region"
assert result["errors"]["base"] == "region_fetch_error" assert result["errors"]["base"] == "region_fetch_error"
@ -260,7 +260,7 @@ async def test_config_flow_invalid_email(
data={CONF_EMAIL: INVALID_EMAIL}, data={CONF_EMAIL: INVALID_EMAIL},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
assert result["errors"]["base"] == "invalid_email" assert result["errors"]["base"] == "invalid_email"
@ -289,7 +289,7 @@ async def test_config_flow_reauth_success(
context={"source": "reauth", "entry_id": mock_entry.entry_id}, context={"source": "reauth", "entry_id": mock_entry.entry_id},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"] == {} assert result["errors"] == {}
@ -299,7 +299,7 @@ async def test_config_flow_reauth_success(
user_input={CONF_CODE: reauth_code}, user_input={CONF_CODE: reauth_code},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_EMAIL: MOCK_EMAIL, CONF_EMAIL: MOCK_EMAIL,
CONF_REGION: MOCK_URL, CONF_REGION: MOCK_URL,
@ -331,7 +331,7 @@ async def test_config_flow_reauth_fail_invalid_code(
context={"source": "reauth", "entry_id": mock_entry.entry_id}, context={"source": "reauth", "entry_id": mock_entry.entry_id},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"] == {} assert result["errors"] == {}
@ -341,7 +341,7 @@ async def test_config_flow_reauth_fail_invalid_code(
user_input={CONF_CODE: reauth_invalid_code}, user_input={CONF_CODE: reauth_invalid_code},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "email_code" assert result["step_id"] == "email_code"
assert result["errors"]["base"] == "invalid_code" assert result["errors"]["base"] == "invalid_code"
@ -368,5 +368,5 @@ async def test_config_flow_reauth_fail_code_request(
context={"source": "reauth", "entry_id": reauth_entry.entry_id}, context={"source": "reauth", "entry_id": reauth_entry.entry_id},
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"

View file

@ -5,9 +5,10 @@ from unittest.mock import ANY
from haphilipsjs import PairingFailure from haphilipsjs import PairingFailure
import pytest import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.philips_js.const import CONF_ALLOW_NOTIFY, DOMAIN from homeassistant.components.philips_js.const import CONF_ALLOW_NOTIFY, DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import ( from . import (
MOCK_CONFIG, MOCK_CONFIG,
@ -78,7 +79,7 @@ async def test_reauth(
data=mock_config_entry.data, data=mock_config_entry.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"] == {} assert result["errors"] == {}
@ -88,7 +89,7 @@ async def test_reauth(
) )
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 mock_config_entry.data == MOCK_CONFIG | {"system": mock_tv.system} assert mock_config_entry.data == MOCK_CONFIG | {"system": mock_tv.system}
assert len(mock_setup_entry.mock_calls) == 2 assert len(mock_setup_entry.mock_calls) == 2
@ -255,12 +256,12 @@ 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(
result["flow_id"], user_input={CONF_ALLOW_NOTIFY: True} result["flow_id"], user_input={CONF_ALLOW_NOTIFY: True}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_ALLOW_NOTIFY: True} assert config_entry.options == {CONF_ALLOW_NOTIFY: True}

View file

@ -32,7 +32,7 @@ async def test_flow_user_with_api_key(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, 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"] == {}
@ -40,7 +40,7 @@ async def test_flow_user_with_api_key(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=CONFIG_FLOW_USER, user_input=CONFIG_FLOW_USER,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_key" assert result["step_id"] == "api_key"
assert result["errors"] == {} assert result["errors"] == {}
@ -48,7 +48,7 @@ async def test_flow_user_with_api_key(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={CONF_API_KEY: "some_key"}, user_input={CONF_API_KEY: "some_key"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_key" assert result["step_id"] == "api_key"
assert result["errors"] == {CONF_API_KEY: "invalid_auth"} assert result["errors"] == {CONF_API_KEY: "invalid_auth"}
@ -57,7 +57,7 @@ async def test_flow_user_with_api_key(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=CONFIG_FLOW_API_KEY, user_input=CONFIG_FLOW_API_KEY,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME assert result["title"] == NAME
assert result["data"] == CONFIG_ENTRY_WITH_API_KEY assert result["data"] == CONFIG_ENTRY_WITH_API_KEY
mock_setup.assert_called_once() mock_setup.assert_called_once()
@ -68,7 +68,7 @@ async def test_flow_user_with_api_key(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data=CONFIG_FLOW_USER, data=CONFIG_FLOW_USER,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -80,7 +80,7 @@ async def test_flow_user_without_api_key(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, 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"] == {}
@ -88,7 +88,7 @@ async def test_flow_user_without_api_key(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=CONFIG_FLOW_USER, user_input=CONFIG_FLOW_USER,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME assert result["title"] == NAME
assert result["data"] == CONFIG_ENTRY_WITHOUT_API_KEY assert result["data"] == CONFIG_ENTRY_WITHOUT_API_KEY
mock_setup.assert_called_once() mock_setup.assert_called_once()
@ -101,7 +101,7 @@ async def test_flow_user_invalid(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=CONFIG_FLOW_USER DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_FLOW_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"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -129,6 +129,6 @@ async def test_flow_reauth(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"] == "reauth_successful" assert result["reason"] == "reauth_successful"
assert entry.data[CONF_API_KEY] == "newkey" assert entry.data[CONF_API_KEY] == "newkey"

View file

@ -6,10 +6,11 @@ import pytest
from python_picnic_api.session import PicnicAuthError from python_picnic_api.session import PicnicAuthError
import requests import requests
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.picnic.const import DOMAIN from homeassistant.components.picnic.const import DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY_CODE from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY_CODE
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
@ -41,7 +42,7 @@ async def test_form(hass: HomeAssistant, picnic_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"
assert result["errors"] is None assert result["errors"] is None
@ -87,7 +88,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"}
@ -110,7 +111,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"}
@ -133,7 +134,7 @@ async def test_form_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"}
@ -160,7 +161,7 @@ async def test_form_already_configured(hass: HomeAssistant, picnic_api) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result_configure["type"] == data_entry_flow.FlowResultType.ABORT assert result_configure["type"] is FlowResultType.ABORT
assert result_configure["reason"] == "already_configured" assert result_configure["reason"] == "already_configured"
@ -179,7 +180,7 @@ async def test_step_reauth(hass: HomeAssistant, picnic_api) -> None:
result_init = await hass.config_entries.flow.async_init( result_init = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf
) )
assert result_init["type"] == data_entry_flow.FlowResultType.FORM assert result_init["type"] is FlowResultType.FORM
assert result_init["step_id"] == "user" assert result_init["step_id"] == "user"
with patch( with patch(
@ -197,7 +198,7 @@ async def test_step_reauth(hass: HomeAssistant, picnic_api) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
# Check that the returned flow has type abort because of successful re-authentication # Check that the returned flow has type abort because of successful re-authentication
assert result_configure["type"] == data_entry_flow.FlowResultType.ABORT assert result_configure["type"] is FlowResultType.ABORT
assert result_configure["reason"] == "reauth_successful" assert result_configure["reason"] == "reauth_successful"
assert len(hass.config_entries.async_entries()) == 1 assert len(hass.config_entries.async_entries()) == 1
@ -219,7 +220,7 @@ async def test_step_reauth_failed(hass: HomeAssistant) -> None:
result_init = await hass.config_entries.flow.async_init( result_init = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf
) )
assert result_init["type"] == data_entry_flow.FlowResultType.FORM assert result_init["type"] is FlowResultType.FORM
assert result_init["step_id"] == "user" assert result_init["step_id"] == "user"
with patch( with patch(
@ -258,7 +259,7 @@ async def test_step_reauth_different_account(hass: HomeAssistant, picnic_api) ->
result_init = await hass.config_entries.flow.async_init( result_init = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=conf
) )
assert result_init["type"] == data_entry_flow.FlowResultType.FORM assert result_init["type"] is FlowResultType.FORM
assert result_init["step_id"] == "user" assert result_init["step_id"] == "user"
with patch( with patch(

View file

@ -27,7 +27,7 @@ async def test_form(hass: HomeAssistant, host, expected_title) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
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"],
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant, host, expected_title) -> 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"] == expected_title assert result["title"] == expected_title
assert result["data"] == {} assert result["data"] == {}
assert result["options"] == { assert result["options"] == {
@ -69,7 +69,7 @@ async def test_options(hass: HomeAssistant, host, count, expected_title) -> 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"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -81,7 +81,7 @@ async def test_options(hass: HomeAssistant, host, count, expected_title) -> 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"] == { assert result["data"] == {
"count": count, "count": count,
"host": "10.10.10.1", "host": "10.10.10.1",
@ -100,7 +100,7 @@ async def test_step_import(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"] == "test2" assert result["title"] == "test2"
assert result["data"] == {CONF_IMPORTED_BY: "binary_sensor"} assert result["data"] == {CONF_IMPORTED_BY: "binary_sensor"}
assert result["options"] == { assert result["options"] == {
@ -117,7 +117,7 @@ async def test_step_import(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.10" assert result["title"] == "10.10.10.10"
assert result["data"] == {CONF_IMPORTED_BY: "binary_sensor"} assert result["data"] == {CONF_IMPORTED_BY: "binary_sensor"}
assert result["options"] == { assert result["options"] == {

View file

@ -5,7 +5,7 @@ from unittest.mock import patch
from pyplaato.models.device import PlaatoDeviceType from pyplaato.models.device import PlaatoDeviceType
import pytest import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.plaato.const import ( from homeassistant.components.plaato.const import (
CONF_DEVICE_NAME, CONF_DEVICE_NAME,
CONF_DEVICE_TYPE, CONF_DEVICE_TYPE,
@ -62,7 +62,7 @@ async def test_show_config_form_device_type_airlock(hass: HomeAssistant) -> None
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert result["data_schema"].schema.get(CONF_TOKEN) == str assert result["data_schema"].schema.get(CONF_TOKEN) == str
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) == bool assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) == bool
@ -76,7 +76,7 @@ async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None:
data={CONF_DEVICE_TYPE: PlaatoDeviceType.Keg, CONF_DEVICE_NAME: "device_name"}, data={CONF_DEVICE_TYPE: PlaatoDeviceType.Keg, CONF_DEVICE_NAME: "device_name"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert result["data_schema"].schema.get(CONF_TOKEN) == str assert result["data_schema"].schema.get(CONF_TOKEN) == str
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is None assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is None
@ -91,7 +91,7 @@ async def test_show_config_form_validate_webhook(
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"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -102,7 +102,7 @@ async def test_show_config_form_validate_webhook(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert await async_setup_component(hass, "cloud", {}) assert await async_setup_component(hass, "cloud", {})
@ -126,7 +126,7 @@ async def test_show_config_form_validate_webhook(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "webhook" assert result["step_id"] == "webhook"
@ -139,7 +139,7 @@ async def test_show_config_form_validate_webhook_not_connected(
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"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -150,7 +150,7 @@ async def test_show_config_form_validate_webhook_not_connected(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert await async_setup_component(hass, "cloud", {}) assert await async_setup_component(hass, "cloud", {})
@ -174,7 +174,7 @@ async def test_show_config_form_validate_webhook_not_connected(
}, },
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cloud_not_connected" assert result["reason"] == "cloud_not_connected"
@ -193,7 +193,7 @@ async def test_show_config_form_validate_token(hass: HomeAssistant) -> None:
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
with patch("homeassistant.components.plaato.async_setup_entry", return_value=True): with patch("homeassistant.components.plaato.async_setup_entry", return_value=True):
@ -201,7 +201,7 @@ async def test_show_config_form_validate_token(hass: HomeAssistant) -> None:
result["flow_id"], user_input={CONF_TOKEN: "valid_token"} result["flow_id"], user_input={CONF_TOKEN: "valid_token"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == PlaatoDeviceType.Keg.name assert result["title"] == PlaatoDeviceType.Keg.name
assert result["data"] == { assert result["data"] == {
CONF_USE_WEBHOOK: False, CONF_USE_WEBHOOK: False,
@ -228,7 +228,7 @@ async def test_show_config_form_no_cloud_webhook(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -239,7 +239,7 @@ async def test_show_config_form_no_cloud_webhook(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "webhook" assert result["step_id"] == "webhook"
assert result["errors"] is None assert result["errors"] is None
@ -262,14 +262,14 @@ async def test_show_config_form_api_method_no_auth_token(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_TOKEN: ""} result["flow_id"], user_input={CONF_TOKEN: ""}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert len(result["errors"]) == 1 assert len(result["errors"]) == 1
assert result["errors"]["base"] == "no_auth_token" assert result["errors"]["base"] == "no_auth_token"
@ -287,14 +287,14 @@ async def test_show_config_form_api_method_no_auth_token(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_TOKEN: ""} result["flow_id"], user_input={CONF_TOKEN: ""}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_method" assert result["step_id"] == "api_method"
assert len(result["errors"]) == 1 assert len(result["errors"]) == 1
assert result["errors"]["base"] == "no_api_method" assert result["errors"]["base"] == "no_api_method"
@ -318,7 +318,7 @@ async def test_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"] == "user" assert result["step_id"] == "user"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -328,7 +328,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_SCAN_INTERVAL] == 10 assert result["data"][CONF_SCAN_INTERVAL] == 10
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -352,7 +352,7 @@ async def test_options_webhook(hass: HomeAssistant, webhook_id) -> 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"] == "webhook" assert result["step_id"] == "webhook"
assert result["description_placeholders"] == {"webhook_url": ""} assert result["description_placeholders"] == {"webhook_url": ""}
@ -363,7 +363,7 @@ async def test_options_webhook(hass: HomeAssistant, webhook_id) -> 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_ID] == CONF_WEBHOOK_ID assert result["data"][CONF_WEBHOOK_ID] == CONF_WEBHOOK_ID
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1

View file

@ -56,7 +56,7 @@ async def test_bad_credentials(
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"
with ( with (
@ -69,14 +69,14 @@ async def test_bad_credentials(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"][CONF_TOKEN] == "faulty_credentials" assert result["errors"][CONF_TOKEN] == "faulty_credentials"
@ -88,7 +88,7 @@ async def test_bad_hostname(
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"
with ( with (
@ -102,14 +102,14 @@ async def test_bad_hostname(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"][CONF_HOST] == "not_found" assert result["errors"][CONF_HOST] == "not_found"
@ -121,7 +121,7 @@ async def test_unknown_exception(
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"
with ( with (
@ -132,13 +132,13 @@ async def test_unknown_exception(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "unknown" assert result["reason"] == "unknown"
@ -155,7 +155,7 @@ async def test_no_servers_found(
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"
with ( with (
@ -165,13 +165,13 @@ async def test_no_servers_found(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"]["base"] == "no_servers" assert result["errors"]["base"] == "no_servers"
@ -186,7 +186,7 @@ async def test_single_available_server(
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"
with ( with (
@ -196,13 +196,13 @@ async def test_single_available_server(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert ( assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400" result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -230,7 +230,7 @@ async def test_multiple_servers_with_selection(
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"
requests_mock.get( requests_mock.get(
@ -244,13 +244,13 @@ async def test_multiple_servers_with_selection(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_server" assert result["step_id"] == "select_server"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -259,7 +259,7 @@ async def test_multiple_servers_with_selection(
CONF_SERVER_IDENTIFIER: MOCK_SERVERS[0][CONF_SERVER_IDENTIFIER] CONF_SERVER_IDENTIFIER: MOCK_SERVERS[0][CONF_SERVER_IDENTIFIER]
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert ( assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400" result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -295,7 +295,7 @@ async def test_adding_last_unconfigured_server(
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"
requests_mock.get( requests_mock.get(
@ -310,13 +310,13 @@ async def test_adding_last_unconfigured_server(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert ( assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400" result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -354,7 +354,7 @@ async def test_all_available_servers_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"
requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account) requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account)
@ -370,13 +370,13 @@ async def test_all_available_servers_configured(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "all_configured" assert result["reason"] == "all_configured"
@ -388,7 +388,7 @@ async def test_option_flow(hass: HomeAssistant, entry, mock_plex_server) -> 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"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings" assert result["step_id"] == "plex_mp_settings"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -399,7 +399,7 @@ async def test_option_flow(hass: HomeAssistant, entry, mock_plex_server) -> None
CONF_MONITORED_USERS: list(mock_plex_server.accounts), CONF_MONITORED_USERS: list(mock_plex_server.accounts),
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
Platform.MEDIA_PLAYER: { Platform.MEDIA_PLAYER: {
CONF_USE_EPISODE_ART: True, CONF_USE_EPISODE_ART: True,
@ -422,7 +422,7 @@ async def test_missing_option_flow(
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"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings" assert result["step_id"] == "plex_mp_settings"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -433,7 +433,7 @@ async def test_missing_option_flow(
CONF_MONITORED_USERS: list(mock_plex_server.accounts), CONF_MONITORED_USERS: list(mock_plex_server.accounts),
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
Platform.MEDIA_PLAYER: { Platform.MEDIA_PLAYER: {
CONF_USE_EPISODE_ART: True, CONF_USE_EPISODE_ART: True,
@ -470,7 +470,7 @@ async def test_option_flow_new_users_available(
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"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings" assert result["step_id"] == "plex_mp_settings"
multiselect_defaults = result["data_schema"].schema["monitored_users"].options multiselect_defaults = result["data_schema"].schema["monitored_users"].options
@ -486,7 +486,7 @@ async def test_external_timed_out(
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"
with ( with (
@ -496,13 +496,13 @@ async def test_external_timed_out(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "token_request_timeout" assert result["reason"] == "token_request_timeout"
@ -515,7 +515,7 @@ async def test_callback_view(
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"
with ( with (
@ -525,7 +525,7 @@ async def test_callback_view(
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.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
client = await hass_client_no_auth() client = await hass_client_no_auth()
forward_url = f'{config_flow.AUTH_CALLBACK_PATH}?flow_id={result["flow_id"]}' forward_url = f'{config_flow.AUTH_CALLBACK_PATH}?flow_id={result["flow_id"]}'
@ -552,7 +552,7 @@ async def test_manual_config(
config_flow.DOMAIN, context={"source": SOURCE_USER} config_flow.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["data_schema"] is None assert result["data_schema"] is None
hass.config_entries.flow.async_abort(result["flow_id"]) hass.config_entries.flow.async_abort(result["flow_id"])
@ -564,7 +564,7 @@ async def test_manual_config(
) )
assert result["data_schema"] is not None assert result["data_schema"] is not None
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced" assert result["step_id"] == "user_advanced"
with patch("plexauth.PlexAuth.initiate_auth"): with patch("plexauth.PlexAuth.initiate_auth"):
@ -572,7 +572,7 @@ async def test_manual_config(
result["flow_id"], user_input={"setup_method": AUTOMATIC_SETUP_STRING} result["flow_id"], user_input={"setup_method": AUTOMATIC_SETUP_STRING}
) )
assert result["type"] == FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
hass.config_entries.flow.async_abort(result["flow_id"]) hass.config_entries.flow.async_abort(result["flow_id"])
# Advanced manual # Advanced manual
@ -582,14 +582,14 @@ async def test_manual_config(
) )
assert result["data_schema"] is not None assert result["data_schema"] is not None
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced" assert result["step_id"] == "user_advanced"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING} result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
MANUAL_SERVER = { MANUAL_SERVER = {
@ -610,7 +610,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER_NO_HOST_OR_TOKEN result["flow_id"], user_input=MANUAL_SERVER_NO_HOST_OR_TOKEN
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "host_or_token" assert result["errors"]["base"] == "host_or_token"
@ -622,7 +622,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER result["flow_id"], user_input=MANUAL_SERVER
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error" assert result["errors"]["base"] == "ssl_error"
@ -634,7 +634,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER result["flow_id"], user_input=MANUAL_SERVER
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error" assert result["errors"]["base"] == "ssl_error"
@ -646,7 +646,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER result["flow_id"], user_input=MANUAL_SERVER
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error" assert result["errors"]["base"] == "ssl_error"
@ -659,7 +659,7 @@ async def test_manual_config(
) )
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"] == "http://1.2.3.4:32400" assert result["title"] == "http://1.2.3.4:32400"
assert result["data"][CONF_SERVER] == "Plex Server 1" assert result["data"][CONF_SERVER] == "Plex Server 1"
@ -682,14 +682,14 @@ async def test_manual_config_with_token(
context={"source": SOURCE_USER, "show_advanced_options": True}, context={"source": SOURCE_USER, "show_advanced_options": True},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced" assert result["step_id"] == "user_advanced"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING} result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup" assert result["step_id"] == "manual_setup"
with ( with (
@ -700,7 +700,7 @@ async def test_manual_config_with_token(
result["flow_id"], user_input={CONF_TOKEN: MOCK_TOKEN} result["flow_id"], user_input={CONF_TOKEN: MOCK_TOKEN}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
mock_url = "https://1-2-3-4.123456789001234567890.plex.direct:32400" mock_url = "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -761,13 +761,13 @@ async def test_reauth(
patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"), patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"),
): ):
result = await hass.config_entries.flow.async_configure(flow_id, user_input={}) result = await hass.config_entries.flow.async_configure(flow_id, user_input={})
assert result["type"] == FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "reauth_successful" assert result["reason"] == "reauth_successful"
assert result["flow_id"] == flow_id assert result["flow_id"] == flow_id
@ -813,13 +813,13 @@ async def test_reauth_multiple_servers_available(
patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"), patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"),
): ):
result = await hass.config_entries.flow.async_configure(flow_id, user_input={}) result = await hass.config_entries.flow.async_configure(flow_id, user_input={})
assert result["type"] == FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
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.EXTERNAL_STEP_DONE assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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["flow_id"] == flow_id assert result["flow_id"] == flow_id
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"
@ -840,7 +840,7 @@ async def test_client_request_missing(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"] == "user" assert result["step_id"] == "user"
with ( with (
@ -864,7 +864,7 @@ async def test_client_header_issues(
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"
with ( with (

View file

@ -120,7 +120,7 @@ async def test_form(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER} DOMAIN, context={CONF_SOURCE: SOURCE_USER}
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -133,7 +133,7 @@ async def test_form(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name" assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == { assert result2.get("data") == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -167,7 +167,7 @@ async def test_zeroconf_flow(
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=discovery, data=discovery,
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -177,7 +177,7 @@ async def test_zeroconf_flow(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name" assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == { assert result2.get("data") == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -202,7 +202,7 @@ async def test_zeroconf_flow_stretch(
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY2, data=TEST_DISCOVERY2,
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -212,7 +212,7 @@ async def test_zeroconf_flow_stretch(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Test Smile Name" assert result2.get("title") == "Test Smile Name"
assert result2.get("data") == { assert result2.get("data") == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -253,7 +253,7 @@ async def test_zercoconf_discovery_update_configuration(
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
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 entry.data[CONF_HOST] == "0.0.0.0" assert entry.data[CONF_HOST] == "0.0.0.0"
@ -264,7 +264,7 @@ async def test_zercoconf_discovery_update_configuration(
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
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 entry.data[CONF_HOST] == "1.1.1.1" assert entry.data[CONF_HOST] == "1.1.1.1"
@ -293,7 +293,7 @@ async def test_flow_errors(
DOMAIN, DOMAIN,
context={CONF_SOURCE: SOURCE_USER}, context={CONF_SOURCE: SOURCE_USER},
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -303,7 +303,7 @@ async def test_flow_errors(
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD}, user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
) )
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": reason} assert result2.get("errors") == {"base": reason}
assert result2.get("step_id") == "user" assert result2.get("step_id") == "user"
@ -316,7 +316,7 @@ async def test_flow_errors(
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD}, user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
) )
assert result3.get("type") == FlowResultType.CREATE_ENTRY assert result3.get("type") is FlowResultType.CREATE_ENTRY
assert result3.get("title") == "Test Smile Name" assert result3.get("title") == "Test Smile Name"
assert result3.get("data") == { assert result3.get("data") == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -341,7 +341,7 @@ async def test_zeroconf_abort_anna_with_existing_config_entries(
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA, data=TEST_DISCOVERY_ANNA,
) )
assert result.get("type") == FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "anna_with_adam" assert result.get("reason") == "anna_with_adam"
@ -352,7 +352,7 @@ async def test_zeroconf_abort_anna_with_adam(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA, data=TEST_DISCOVERY_ANNA,
) )
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"
flows_in_progress = hass.config_entries.flow.async_progress() flows_in_progress = hass.config_entries.flow.async_progress()
@ -366,7 +366,7 @@ async def test_zeroconf_abort_anna_with_adam(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY_ADAM, data=TEST_DISCOVERY_ADAM,
) )
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"
flows_in_progress = hass.config_entries.flow.async_progress() flows_in_progress = hass.config_entries.flow.async_progress()
@ -379,7 +379,7 @@ async def test_zeroconf_abort_anna_with_adam(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_ZEROCONF}, context={CONF_SOURCE: SOURCE_ZEROCONF},
data=TEST_DISCOVERY_ANNA, data=TEST_DISCOVERY_ANNA,
) )
assert result3.get("type") == FlowResultType.ABORT assert result3.get("type") is FlowResultType.ABORT
assert result3.get("reason") == "anna_with_adam" assert result3.get("reason") == "anna_with_adam"
# Adam should still be there # Adam should still be there

View file

@ -4,10 +4,10 @@ from unittest.mock import AsyncMock, patch
import pytest import pytest
from homeassistant import data_entry_flow
from homeassistant.components.point import DOMAIN, config_flow from homeassistant.components.point import DOMAIN, config_flow
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
def init_config_flow(hass, side_effect=None): def init_config_flow(hass, side_effect=None):
@ -49,7 +49,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"] == "no_flows" assert result["reason"] == "no_flows"
@ -59,12 +59,12 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
with patch.object(hass.config_entries, "async_entries", return_value=[{}]): with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
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"] == "already_setup" assert result["reason"] == "already_setup"
with patch.object(hass.config_entries, "async_entries", return_value=[{}]): with patch.object(hass.config_entries, "async_entries", return_value=[{}]):
result = await flow.async_step_import() result = await flow.async_step_import()
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_setup" assert result["reason"] == "already_setup"
@ -74,18 +74,18 @@ async def test_full_flow_implementation(hass: HomeAssistant, mock_pypoint) -> No
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"}) result = await flow.async_step_user({"flow_impl": "test"})
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": "https://example.com" "authorization_url": "https://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["data"]["refresh_args"] == { assert result["data"]["refresh_args"] == {
CONF_CLIENT_ID: "id", CONF_CLIENT_ID: "id",
CONF_CLIENT_SECRET: "secret", CONF_CLIENT_SECRET: "secret",
@ -99,7 +99,7 @@ async def test_step_import(hass: HomeAssistant, mock_pypoint) -> 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"
@ -111,7 +111,7 @@ async def test_wrong_code_flow_implementation(
flow = init_config_flow(hass) flow = init_config_flow(hass)
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"] == "auth_error" assert result["reason"] == "auth_error"
@ -120,7 +120,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"
@ -129,7 +129,7 @@ async def test_abort_if_timeout_generating_auth_url(hass: HomeAssistant) -> None
flow = init_config_flow(hass, side_effect=TimeoutError) flow = init_config_flow(hass, side_effect=TimeoutError)
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"] == "authorize_url_timeout" assert result["reason"] == "authorize_url_timeout"
@ -138,7 +138,7 @@ async def test_abort_if_exception_generating_auth_url(hass: HomeAssistant) -> No
flow = init_config_flow(hass, side_effect=ValueError) flow = init_config_flow(hass, side_effect=ValueError)
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"] == "unknown_authorize_url_generation" assert result["reason"] == "unknown_authorize_url_generation"
@ -147,5 +147,5 @@ async def test_abort_no_code(hass: HomeAssistant) -> None:
flow = init_config_flow(hass) flow = init_config_flow(hass)
result = await flow.async_step_code() result = await flow.async_step_code()
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_code" assert result["reason"] == "no_code"

View file

@ -2,11 +2,11 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant.components.poolsense.const import DOMAIN from homeassistant.components.poolsense.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_show_form(hass: HomeAssistant) -> None: async def test_show_form(hass: HomeAssistant) -> None:
@ -15,7 +15,7 @@ async def test_show_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"
@ -50,7 +50,7 @@ async def test_valid_credentials(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"] == "test-email" assert result["title"] == "test-email"
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1

View file

@ -321,7 +321,7 @@ async def test_dhcp_discovery_cannot_connect(hass: HomeAssistant) -> None:
hostname="00GGX", hostname="00GGX",
), ),
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -399,7 +399,7 @@ async def test_dhcp_discovery_update_ip_address(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_IP_ADDRESS] == "1.1.1.1" assert entry.data[CONF_IP_ADDRESS] == "1.1.1.1"
@ -436,7 +436,7 @@ async def test_dhcp_discovery_does_not_update_ip_when_auth_fails(
), ),
) )
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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
@ -473,7 +473,7 @@ async def test_dhcp_discovery_does_not_update_ip_when_auth_successful(
), ),
) )
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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
@ -508,7 +508,7 @@ async def test_dhcp_discovery_updates_unique_id(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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
assert entry.unique_id == MOCK_GATEWAY_DIN assert entry.unique_id == MOCK_GATEWAY_DIN
@ -547,7 +547,7 @@ async def test_dhcp_discovery_updates_unique_id_when_entry_is_failed(
), ),
) )
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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
assert entry.unique_id == MOCK_GATEWAY_DIN assert entry.unique_id == MOCK_GATEWAY_DIN
@ -586,7 +586,7 @@ async def test_discovered_wifi_does_not_update_ip_if_is_still_online(
), ),
) )
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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"
@ -635,6 +635,6 @@ async def test_discovered_wifi_does_not_update_ip_online_but_access_denied(
), ),
) )
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_IP_ADDRESS] == "1.2.3.4" assert entry.data[CONF_IP_ADDRESS] == "1.2.3.4"

View file

@ -26,7 +26,7 @@ async def test_setup_user_no_bluetooth(
const.DOMAIN, const.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"] == "bluetooth_not_available" assert result["reason"] == "bluetooth_not_available"
@ -114,7 +114,7 @@ async def test_flow_works(hass: HomeAssistant, enable_bluetooth: None) -> None:
user_input={"irk": "irk:00000000000000000000000000000000"}, user_input={"irk": "irk:00000000000000000000000000000000"},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Test Test Test" assert result["title"] == "Test Test Test"
assert result["data"] == {"irk": "00000000000000000000000000000000"} assert result["data"] == {"irk": "00000000000000000000000000000000"}
assert result["result"].unique_id == "00000000000000000000000000000000" assert result["result"].unique_id == "00000000000000000000000000000000"
@ -153,7 +153,7 @@ async def test_flow_works_by_base64(
user_input={"irk": "AAAAAAAAAAAAAAAAAAAAAA=="}, user_input={"irk": "AAAAAAAAAAAAAAAAAAAAAA=="},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Test Test Test" assert result["title"] == "Test Test Test"
assert result["data"] == {"irk": "00000000000000000000000000000000"} assert result["data"] == {"irk": "00000000000000000000000000000000"}
assert result["result"].unique_id == "00000000000000000000000000000000" assert result["result"].unique_id == "00000000000000000000000000000000"

View file

@ -24,7 +24,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["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -41,7 +41,7 @@ async def test_form(hass: HomeAssistant) -> None:
{CONF_HOST: "", CONF_PORT: 80}, {CONF_HOST: "", CONF_PORT: 80},
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "relay_modes" assert result2["step_id"] == "relay_modes"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -54,7 +54,7 @@ async def test_form(hass: HomeAssistant) -> None:
mock_value_step_rm, mock_value_step_rm,
) )
assert result3["type"] == FlowResultType.CREATE_ENTRY assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] assert result3["data"]
assert result3["data"]["title"] == "1R & 1IN Board" assert result3["data"]["title"] == "1R & 1IN Board"
assert result3["data"]["is_old"] is False assert result3["data"]["is_old"] is False
@ -78,7 +78,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
{CONF_HOST: "", CONF_PORT: 80}, {CONF_HOST: "", CONF_PORT: 80},
) )
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"}
@ -105,7 +105,7 @@ async def test_form_existing_entry_exception(hass: HomeAssistant) -> None:
{CONF_HOST: "", CONF_PORT: 80}, {CONF_HOST: "", CONF_PORT: 80},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -126,6 +126,6 @@ async def test_form_user_exception(hass: HomeAssistant) -> None:
{CONF_HOST: "", CONF_PORT: 80}, {CONF_HOST: "", CONF_PORT: 80},
) )
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"}

View file

@ -153,7 +153,7 @@ async def test_reauth_flow(hass: HomeAssistant, mock_list_contracts) -> None:
data=entry.data, data=entry.data,
) )
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -175,7 +175,7 @@ async def test_reauth_flow(hass: HomeAssistant, mock_list_contracts) -> 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 entry.data == { assert entry.data == {
"country": "PT", "country": "PT",
@ -231,5 +231,5 @@ async def test_reauth_flow_error(hass: HomeAssistant, exception, base_error) ->
) )
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"] == base_error assert result2["errors"]["base"] == base_error

View file

@ -56,7 +56,7 @@ async def test_user_flow(
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"
with patch( with patch(
@ -66,7 +66,7 @@ async def test_user_flow(
result["flow_id"], result["flow_id"],
user_input=user_input, user_input=user_input,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == expected_result assert result["data"] == expected_result
zone = hass.states.get(user_input[CONF_ZONE]) zone = hass.states.get(user_input[CONF_ZONE])
@ -101,7 +101,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
assert mock_setup_entry.called assert mock_setup_entry.called
result = await hass.config_entries.options.async_init(mock_config.entry_id) result = await hass.config_entries.options.async_init(mock_config.entry_id)
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(
result["flow_id"], result["flow_id"],
@ -111,7 +111,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_TOLERANCE: 1, CONF_TOLERANCE: 1,
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert mock_config.data == { assert mock_config.data == {
CONF_ZONE: "zone.home", CONF_ZONE: "zone.home",
CONF_TRACKED_ENTITIES: ["device_tracker.test2"], CONF_TRACKED_ENTITIES: ["device_tracker.test2"],
@ -138,7 +138,7 @@ async def test_import_flow(hass: HomeAssistant) -> None:
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_NAME: "home", CONF_NAME: "home",
CONF_ZONE: "zone.home", CONF_ZONE: "zone.home",
@ -182,7 +182,7 @@ async def test_abort_duplicated_entry(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=DATA, user_input=DATA,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -229,7 +229,7 @@ async def test_avoid_duplicated_title(hass: HomeAssistant) -> None:
CONF_TOLERANCE: 10, CONF_TOLERANCE: 10,
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "home 2" assert result["title"] == "home 2"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -246,7 +246,7 @@ async def test_avoid_duplicated_title(hass: HomeAssistant) -> None:
CONF_TOLERANCE: 10, CONF_TOLERANCE: 10,
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "home 4" assert result["title"] == "home 4"
await hass.async_block_till_done() await hass.async_block_till_done()

View file

@ -14,7 +14,7 @@ async def test_form(hass: HomeAssistant, mock_version_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"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with patch( with patch(
@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant, mock_version_api) -> 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"] == "PrusaXL" assert result2["title"] == "PrusaXL"
assert result2["data"] == { assert result2["data"] == {
"host": "http://1.1.1.1", "host": "http://1.1.1.1",
@ -65,7 +65,7 @@ async def test_form_mk3(hass: HomeAssistant, mock_version_api) -> 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 len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -88,7 +88,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"}
@ -111,7 +111,7 @@ async def test_form_unknown(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -132,7 +132,7 @@ async def test_form_too_low_version(hass: HomeAssistant, mock_version_api) -> No
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "not_supported"} assert result2["errors"] == {"base": "not_supported"}
@ -153,7 +153,7 @@ async def test_form_invalid_version_2(hass: HomeAssistant, mock_version_api) ->
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "not_supported"} assert result2["errors"] == {"base": "not_supported"}
@ -178,7 +178,7 @@ async def test_form_invalid_mk3_server_version(
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "not_supported"} assert result2["errors"] == {"base": "not_supported"}
@ -201,5 +201,5 @@ 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"}

View file

@ -5,7 +5,7 @@ from unittest.mock import patch
from pyps4_2ndscreen.errors import CredentialTimeout from pyps4_2ndscreen.errors import CredentialTimeout
import pytest import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components import ps4 from homeassistant.components import ps4
from homeassistant.components.ps4.config_flow import LOCAL_UDP_PORT from homeassistant.components.ps4.config_flow import LOCAL_UDP_PORT
from homeassistant.components.ps4.const import ( from homeassistant.components.ps4.const import (
@ -23,6 +23,7 @@ from homeassistant.const import (
CONF_TOKEN, CONF_TOKEN,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.util import location from homeassistant.util import location
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -105,7 +106,7 @@ async def test_full_flow_implementation(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["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
@ -113,7 +114,7 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
@ -123,7 +124,7 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
# User Input results in created entry. # User Input results in created entry.
@ -136,7 +137,7 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_CONFIG result["flow_id"], user_input=MOCK_CONFIG
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
assert result["data"]["devices"] == [MOCK_DEVICE] assert result["data"]["devices"] == [MOCK_DEVICE]
assert result["title"] == MOCK_TITLE assert result["title"] == MOCK_TITLE
@ -149,7 +150,7 @@ async def test_multiple_flow_implementation(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["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
@ -157,7 +158,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
@ -168,7 +169,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
# User Input results in created entry. # User Input results in created entry.
@ -182,7 +183,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_CONFIG result["flow_id"], user_input=MOCK_CONFIG
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
assert result["data"]["devices"] == [MOCK_DEVICE] assert result["data"]["devices"] == [MOCK_DEVICE]
assert result["title"] == MOCK_TITLE assert result["title"] == MOCK_TITLE
@ -207,7 +208,7 @@ async def test_multiple_flow_implementation(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["step_id"] == "creds" assert result["step_id"] == "creds"
# Step Creds results with form in Step Mode. # Step Creds results with form in Step Mode.
@ -215,7 +216,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input which is not manual, results in Step Link. # Step Mode with User Input which is not manual, results in Step Link.
@ -226,7 +227,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
# Step Link # Step Link
@ -240,7 +241,7 @@ async def test_multiple_flow_implementation(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_CONFIG_ADDITIONAL result["flow_id"], user_input=MOCK_CONFIG_ADDITIONAL
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
assert len(result["data"]["devices"]) == 1 assert len(result["data"]["devices"]) == 1
assert result["title"] == MOCK_TITLE assert result["title"] == MOCK_TITLE
@ -263,7 +264,7 @@ async def test_port_bind_abort(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"] == reason assert result["reason"] == reason
with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_TCP_PORT): with patch("pyps4_2ndscreen.Helper.port_bind", return_value=MOCK_TCP_PORT):
@ -271,7 +272,7 @@ async def test_port_bind_abort(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"] == reason assert result["reason"] == reason
@ -283,14 +284,14 @@ async def test_duplicate_abort(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["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with patch( with patch(
@ -299,7 +300,7 @@ async def test_duplicate_abort(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -313,14 +314,14 @@ async def test_additional_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with patch( with patch(
@ -336,7 +337,7 @@ async def test_additional_device(hass: HomeAssistant) -> None:
result["flow_id"], user_input=MOCK_CONFIG_ADDITIONAL result["flow_id"], user_input=MOCK_CONFIG_ADDITIONAL
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_TOKEN] == MOCK_CREDS assert result["data"][CONF_TOKEN] == MOCK_CREDS
assert len(result["data"]["devices"]) == 1 assert len(result["data"]["devices"]) == 1
assert result["title"] == MOCK_TITLE assert result["title"] == MOCK_TITLE
@ -350,7 +351,7 @@ async def test_0_pin(hass: HomeAssistant) -> None:
context={"source": "creds"}, context={"source": "creds"},
data={}, data={},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with ( with (
@ -365,7 +366,7 @@ async def test_0_pin(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], MOCK_AUTO result["flow_id"], MOCK_AUTO
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
mock_config = MOCK_CONFIG mock_config = MOCK_CONFIG
@ -390,14 +391,14 @@ async def test_no_devices_found_abort(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["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with patch("pyps4_2ndscreen.Helper.has_devices", return_value=[]): with patch("pyps4_2ndscreen.Helper.has_devices", return_value=[]):
@ -405,7 +406,7 @@ async def test_no_devices_found_abort(hass: HomeAssistant) -> None:
result["flow_id"], user_input=MOCK_AUTO result["flow_id"], user_input=MOCK_AUTO
) )
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"
@ -415,14 +416,14 @@ async def test_manual_mode(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["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
# Step Mode with User Input: manual, results in Step Link. # Step Mode with User Input: manual, results in Step Link.
@ -433,7 +434,7 @@ async def test_manual_mode(hass: HomeAssistant) -> None:
result["flow_id"], user_input=MOCK_MANUAL result["flow_id"], user_input=MOCK_MANUAL
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
@ -443,7 +444,7 @@ async def test_credential_abort(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["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=None): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=None):
@ -451,7 +452,7 @@ async def test_credential_abort(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "credential_error" assert result["reason"] == "credential_error"
@ -461,7 +462,7 @@ async def test_credential_timeout(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["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", side_effect=CredentialTimeout): with patch("pyps4_2ndscreen.Helper.get_creds", side_effect=CredentialTimeout):
@ -469,7 +470,7 @@ async def test_credential_timeout(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
assert result["errors"] == {"base": "credential_timeout"} assert result["errors"] == {"base": "credential_timeout"}
@ -480,14 +481,14 @@ async def test_wrong_pin_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with patch( with patch(
@ -501,7 +502,7 @@ async def test_wrong_pin_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_CONFIG result["flow_id"], user_input=MOCK_CONFIG
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "login_failed"} assert result["errors"] == {"base": "login_failed"}
@ -512,14 +513,14 @@ async def test_device_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
with patch( with patch(
@ -533,7 +534,7 @@ async def test_device_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_CONFIG result["flow_id"], user_input=MOCK_CONFIG
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -544,20 +545,20 @@ async def test_manual_mode_no_ip_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "creds" assert result["step_id"] == "creds"
with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS): with patch("pyps4_2ndscreen.Helper.get_creds", return_value=MOCK_CREDS):
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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"Config Mode": "Manual Entry"} result["flow_id"], user_input={"Config Mode": "Manual Entry"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mode" assert result["step_id"] == "mode"
assert result["errors"] == {CONF_IP_ADDRESS: "no_ipaddress"} assert result["errors"] == {CONF_IP_ADDRESS: "no_ipaddress"}

View file

@ -25,14 +25,14 @@ 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
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "192.168.1.123"} result["flow_id"], user_input={CONF_HOST: "192.168.1.123"}
) )
assert result.get("title") == "Pure Energie Meter" assert result.get("title") == "Pure Energie Meter"
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert "data" in result assert "data" in result
assert result["data"][CONF_HOST] == "192.168.1.123" assert result["data"][CONF_HOST] == "192.168.1.123"
assert "result" in result assert "result" in result
@ -64,14 +64,14 @@ async def test_full_zeroconf_flow_implementationn(
CONF_NAME: "Pure Energie Meter", CONF_NAME: "Pure Energie Meter",
} }
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
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.get("title") == "Pure Energie Meter" assert result2.get("title") == "Pure Energie Meter"
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"
@ -90,7 +90,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"}
@ -115,5 +115,5 @@ 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"

View file

@ -5,10 +5,10 @@ from unittest.mock import AsyncMock, patch
from aiopurpleair.errors import InvalidApiKeyError, PurpleAirError from aiopurpleair.errors import InvalidApiKeyError, PurpleAirError
import pytest import pytest
from homeassistant import data_entry_flow
from homeassistant.components.purpleair import DOMAIN from homeassistant.components.purpleair import DOMAIN
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from .conftest import TEST_API_KEY, TEST_SENSOR_INDEX1, TEST_SENSOR_INDEX2 from .conftest import TEST_API_KEY, TEST_SENSOR_INDEX1, TEST_SENSOR_INDEX2
@ -46,7 +46,7 @@ async def test_create_entry_by_coordinates(
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 checking the API key: # Test errors that can arise when checking the API key:
@ -54,13 +54,13 @@ async def test_create_entry_by_coordinates(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"api_key": TEST_API_KEY} result["flow_id"], user_input={"api_key": TEST_API_KEY}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == check_api_key_errors assert result["errors"] == check_api_key_errors
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"api_key": TEST_API_KEY} result["flow_id"], user_input={"api_key": TEST_API_KEY}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "by_coordinates" assert result["step_id"] == "by_coordinates"
# Test errors that can arise when searching for nearby sensors: # Test errors that can arise when searching for nearby sensors:
@ -73,7 +73,7 @@ async def test_create_entry_by_coordinates(
"distance": 5, "distance": 5,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == get_nearby_sensors_errors assert result["errors"] == get_nearby_sensors_errors
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -84,7 +84,7 @@ async def test_create_entry_by_coordinates(
"distance": 5, "distance": 5,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "choose_sensor" assert result["step_id"] == "choose_sensor"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -93,7 +93,7 @@ async def test_create_entry_by_coordinates(
"sensor_index": str(TEST_SENSOR_INDEX1), "sensor_index": str(TEST_SENSOR_INDEX1),
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "abcde" assert result["title"] == "abcde"
assert result["data"] == { assert result["data"] == {
"api_key": TEST_API_KEY, "api_key": TEST_API_KEY,
@ -110,7 +110,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={"api_key": TEST_API_KEY} DOMAIN, context={"source": SOURCE_USER}, data={"api_key": TEST_API_KEY}
) )
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,7 +140,7 @@ async def test_reauth(
}, },
data={"api_key": TEST_API_KEY}, data={"api_key": TEST_API_KEY},
) )
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"
# Test errors that can arise when checking the API key: # Test errors that can arise when checking the API key:
@ -148,14 +148,14 @@ 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={"api_key": "new_api_key"} result["flow_id"], user_input={"api_key": "new_api_key"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == check_api_key_errors assert result["errors"] == check_api_key_errors
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
user_input={"api_key": "new_api_key"}, user_input={"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
# Unload to make sure the update does not run after the # Unload to make sure the update does not run after the
@ -181,13 +181,13 @@ async def test_options_add_sensor(
) -> None: ) -> None:
"""Test adding a sensor via the options flow (including errors).""" """Test adding a sensor via the options flow (including errors)."""
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.MENU assert result["type"] is FlowResultType.MENU
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={"next_step_id": "add_sensor"} result["flow_id"], user_input={"next_step_id": "add_sensor"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "add_sensor" assert result["step_id"] == "add_sensor"
# Test errors that can arise when searching for nearby sensors: # Test errors that can arise when searching for nearby sensors:
@ -202,7 +202,7 @@ async def test_options_add_sensor(
"distance": 5, "distance": 5,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "add_sensor" assert result["step_id"] == "add_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -213,7 +213,7 @@ async def test_options_add_sensor(
"distance": 5, "distance": 5,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "choose_sensor" assert result["step_id"] == "choose_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -222,7 +222,7 @@ async def test_options_add_sensor(
"sensor_index": str(TEST_SENSOR_INDEX2), "sensor_index": str(TEST_SENSOR_INDEX2),
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"sensor_indices": [TEST_SENSOR_INDEX1, TEST_SENSOR_INDEX2], "sensor_indices": [TEST_SENSOR_INDEX1, TEST_SENSOR_INDEX2],
} }
@ -241,13 +241,13 @@ async def test_options_add_sensor_duplicate(
) -> None: ) -> None:
"""Test adding a duplicate sensor via the options flow.""" """Test adding a duplicate sensor via the options flow."""
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.MENU assert result["type"] is FlowResultType.MENU
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={"next_step_id": "add_sensor"} result["flow_id"], user_input={"next_step_id": "add_sensor"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "add_sensor" assert result["step_id"] == "add_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -258,7 +258,7 @@ async def test_options_add_sensor_duplicate(
"distance": 5, "distance": 5,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "choose_sensor" assert result["step_id"] == "choose_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -267,7 +267,7 @@ async def test_options_add_sensor_duplicate(
"sensor_index": str(TEST_SENSOR_INDEX1), "sensor_index": str(TEST_SENSOR_INDEX1),
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
# Unload to make sure the update does not run after the # Unload to make sure the update does not run after the
# mock is removed. # mock is removed.
@ -279,13 +279,13 @@ async def test_options_remove_sensor(
) -> None: ) -> None:
"""Test removing a sensor via the options flow.""" """Test removing a sensor via the options flow."""
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.MENU assert result["type"] is FlowResultType.MENU
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={"next_step_id": "remove_sensor"} result["flow_id"], user_input={"next_step_id": "remove_sensor"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "remove_sensor" assert result["step_id"] == "remove_sensor"
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)
@ -296,7 +296,7 @@ async def test_options_remove_sensor(
result["flow_id"], result["flow_id"],
user_input={"sensor_device_id": device_entry.id}, user_input={"sensor_device_id": device_entry.id},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"sensor_indices": [], "sensor_indices": [],
} }
@ -312,19 +312,19 @@ async def test_options_settings(
) -> None: ) -> None:
"""Test setting settings via the options flow.""" """Test setting settings via the options flow."""
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.MENU assert result["type"] is FlowResultType.MENU
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={"next_step_id": "settings"} result["flow_id"], user_input={"next_step_id": "settings"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "settings" assert result["step_id"] == "settings"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"show_on_map": True} result["flow_id"], user_input={"show_on_map": True}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"sensor_indices": [TEST_SENSOR_INDEX1], "sensor_indices": [TEST_SENSOR_INDEX1],
"show_on_map": True, "show_on_map": True,

View file

@ -35,7 +35,7 @@ async def test_flow_user(hass: HomeAssistant, requests_mock_fixture) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "pushbullet" assert result["title"] == "pushbullet"
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
@ -60,7 +60,7 @@ async def test_flow_user_already_configured(
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -85,7 +85,7 @@ async def test_flow_name_already_configured(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=new_config, user_input=new_config,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -101,7 +101,7 @@ async def test_flow_invalid_key(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
assert result["type"] == 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"}
@ -118,6 +118,6 @@ async def test_flow_conn_error(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
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"}

View file

@ -44,7 +44,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Pushover" assert result["title"] == "Pushover"
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
@ -66,7 +66,7 @@ async def test_flow_user_key_api_key_exists(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -91,7 +91,7 @@ async def test_flow_name_already_configured(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=new_config, user_input=new_config,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -106,7 +106,7 @@ async def test_flow_invalid_user_key(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {CONF_USER_KEY: "invalid_user_key"} assert result["errors"] == {CONF_USER_KEY: "invalid_user_key"}
@ -122,7 +122,7 @@ async def test_flow_invalid_api_key(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
assert result["type"] == 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"}
@ -136,7 +136,7 @@ async def test_flow_conn_err(hass: HomeAssistant, mock_pushover: MagicMock) -> N
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
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"}
@ -158,7 +158,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
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(
@ -168,7 +168,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful" assert result2["reason"] == "reauth_successful"
@ -200,7 +200,7 @@ async def test_reauth_failed(hass: HomeAssistant, mock_pushover: MagicMock) -> N
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == { assert result2["errors"] == {
CONF_API_KEY: "invalid_api_key", CONF_API_KEY: "invalid_api_key",
} }
@ -232,7 +232,7 @@ async def test_reauth_with_existing_config(hass: HomeAssistant) -> None:
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
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(
@ -242,5 +242,5 @@ async def test_reauth_with_existing_config(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -23,7 +23,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(
@ -34,7 +34,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") == "12345" assert result2.get("title") == "12345"
assert result2.get("data") == { assert result2.get("data") == {
CONF_SYSTEM_ID: 12345, CONF_SYSTEM_ID: 12345,
@ -59,7 +59,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_pvoutput.system.side_effect = PVOutputAuthenticationError mock_pvoutput.system.side_effect = PVOutputAuthenticationError
@ -71,7 +71,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") == {"base": "invalid_auth"} assert result2.get("errors") == {"base": "invalid_auth"}
@ -87,7 +87,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") == "12345" assert result3.get("title") == "12345"
assert result3.get("data") == { assert result3.get("data") == {
CONF_SYSTEM_ID: 12345, CONF_SYSTEM_ID: 12345,
@ -111,7 +111,7 @@ async def test_connection_error(hass: HomeAssistant, mock_pvoutput: MagicMock) -
}, },
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": "cannot_connect"} assert result.get("errors") == {"base": "cannot_connect"}
assert len(mock_pvoutput.system.mock_calls) == 1 assert len(mock_pvoutput.system.mock_calls) == 1
@ -137,7 +137,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"
@ -159,7 +159,7 @@ async def test_reauth_flow(
}, },
data=mock_config_entry.data, data=mock_config_entry.data,
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "reauth_confirm" assert result.get("step_id") == "reauth_confirm"
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -168,7 +168,7 @@ async def test_reauth_flow(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
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_SYSTEM_ID: 12345, CONF_SYSTEM_ID: 12345,
@ -201,7 +201,7 @@ async def test_reauth_with_authentication_error(
}, },
data=mock_config_entry.data, data=mock_config_entry.data,
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "reauth_confirm" assert result.get("step_id") == "reauth_confirm"
mock_pvoutput.system.side_effect = PVOutputAuthenticationError mock_pvoutput.system.side_effect = PVOutputAuthenticationError
@ -211,7 +211,7 @@ async def test_reauth_with_authentication_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") is FlowResultType.FORM
assert result2.get("step_id") == "reauth_confirm" assert result2.get("step_id") == "reauth_confirm"
assert result2.get("errors") == {"base": "invalid_auth"} assert result2.get("errors") == {"base": "invalid_auth"}
@ -225,7 +225,7 @@ async def test_reauth_with_authentication_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3.get("type") == FlowResultType.ABORT assert result3.get("type") is FlowResultType.ABORT
assert result3.get("reason") == "reauth_successful" assert result3.get("reason") == "reauth_successful"
assert mock_config_entry.data == { assert mock_config_entry.data == {
CONF_SYSTEM_ID: 12345, CONF_SYSTEM_ID: 12345,
@ -253,7 +253,7 @@ async def test_reauth_api_error(
}, },
data=mock_config_entry.data, data=mock_config_entry.data,
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "reauth_confirm" assert result.get("step_id") == "reauth_confirm"
mock_pvoutput.system.side_effect = PVOutputConnectionError mock_pvoutput.system.side_effect = PVOutputConnectionError
@ -263,6 +263,6 @@ async def test_reauth_api_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") is FlowResultType.FORM
assert result2.get("step_id") == "reauth_confirm" assert result2.get("step_id") == "reauth_confirm"
assert result2.get("errors") == {"base": "cannot_connect"} assert result2.get("errors") == {"base": "cannot_connect"}

View file

@ -4,7 +4,7 @@ from datetime import datetime, timedelta
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.pvpc_hourly_pricing.const import ( from homeassistant.components.pvpc_hourly_pricing.const import (
ATTR_POWER, ATTR_POWER,
ATTR_POWER_P3, ATTR_POWER_P3,
@ -15,6 +15,7 @@ from homeassistant.components.pvpc_hourly_pricing.const import (
) )
from homeassistant.const import CONF_API_TOKEN, CONF_NAME from homeassistant.const import CONF_API_TOKEN, CONF_NAME
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 homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -53,12 +54,12 @@ async def test_config_flow(
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
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], tst_config result["flow_id"], tst_config
) )
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("sensor.esios_pvpc") state = hass.states.get("sensor.esios_pvpc")
@ -73,11 +74,11 @@ async def test_config_flow(
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
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], tst_config result["flow_id"], tst_config
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert pvpc_aioclient_mock.call_count == 1 assert pvpc_aioclient_mock.call_count == 1
# Check removal # Check removal
@ -89,12 +90,12 @@ async def test_config_flow(
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
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], tst_config result["flow_id"], tst_config
) )
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("sensor.esios_pvpc") state = hass.states.get("sensor.esios_pvpc")
@ -110,21 +111,21 @@ async def test_config_flow(
config_entry = current_entries[0] config_entry = current_entries[0]
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"], result["flow_id"],
user_input={ATTR_POWER: 3.0, ATTR_POWER_P3: 4.6, CONF_USE_API_TOKEN: True}, user_input={ATTR_POWER: 3.0, ATTR_POWER_P3: 4.6, CONF_USE_API_TOKEN: True},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_token" assert result["step_id"] == "api_token"
assert pvpc_aioclient_mock.call_count == 2 assert pvpc_aioclient_mock.call_count == 2
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_API_TOKEN: "test-token"} result["flow_id"], user_input={CONF_API_TOKEN: "test-token"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert pvpc_aioclient_mock.call_count == 2 assert pvpc_aioclient_mock.call_count == 2
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get("sensor.esios_pvpc") state = hass.states.get("sensor.esios_pvpc")
@ -154,14 +155,14 @@ async def test_config_flow(
# disable api token in options # disable api token in 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"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], result["flow_id"],
user_input={ATTR_POWER: 3.0, ATTR_POWER_P3: 4.6, CONF_USE_API_TOKEN: False}, user_input={ATTR_POWER: 3.0, ATTR_POWER_P3: 4.6, CONF_USE_API_TOKEN: False},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert pvpc_aioclient_mock.call_count == 6 assert pvpc_aioclient_mock.call_count == 6
await hass.async_block_till_done() await hass.async_block_till_done()
assert pvpc_aioclient_mock.call_count == 7 assert pvpc_aioclient_mock.call_count == 7
@ -195,19 +196,19 @@ async def test_reauth(
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
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], tst_config result["flow_id"], tst_config
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_token" assert result["step_id"] == "api_token"
assert pvpc_aioclient_mock.call_count == 0 assert pvpc_aioclient_mock.call_count == 0
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_API_TOKEN: "test-token"} result["flow_id"], user_input={CONF_API_TOKEN: "test-token"}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "api_token" assert result["step_id"] == "api_token"
assert result["errors"]["base"] == "invalid_auth" assert result["errors"]["base"] == "invalid_auth"
assert pvpc_aioclient_mock.call_count == 1 assert pvpc_aioclient_mock.call_count == 1
@ -216,7 +217,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_API_TOKEN: "test-token"} result["flow_id"], user_input={CONF_API_TOKEN: "test-token"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
config_entry = result["result"] config_entry = result["result"]
assert pvpc_aioclient_mock.call_count == 4 assert pvpc_aioclient_mock.call_count == 4
@ -234,7 +235,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_API_TOKEN: "test-token"} result["flow_id"], user_input={CONF_API_TOKEN: "test-token"}
) )
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 pvpc_aioclient_mock.call_count == 7 assert pvpc_aioclient_mock.call_count == 7
@ -248,7 +249,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_API_TOKEN: "test-token"} result["flow_id"], user_input={CONF_API_TOKEN: "test-token"}
) )
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 pvpc_aioclient_mock.call_count == 8 assert pvpc_aioclient_mock.call_count == 8

View file

@ -40,7 +40,7 @@ async def test_flow_user(hass: HomeAssistant, mock_api: requests_mock.Mocker) ->
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER} DOMAIN, 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"
# Test flow with connection failure, fail with cannot_connect # Test flow with connection failure, fail with cannot_connect
@ -53,7 +53,7 @@ async def test_flow_user(hass: HomeAssistant, mock_api: requests_mock.Mocker) ->
result["flow_id"], USER_INPUT result["flow_id"], USER_INPUT
) )
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"}
@ -69,7 +69,7 @@ async def test_flow_user(hass: HomeAssistant, mock_api: requests_mock.Mocker) ->
result["flow_id"], USER_INPUT result["flow_id"], USER_INPUT
) )
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"}
@ -78,7 +78,7 @@ async def test_flow_user(hass: HomeAssistant, mock_api: requests_mock.Mocker) ->
result["flow_id"], USER_INPUT result["flow_id"], USER_INPUT
) )
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_URL: "http://localhost:8080", CONF_URL: "http://localhost:8080",
CONF_USERNAME: "user", CONF_USERNAME: "user",
@ -96,12 +96,12 @@ async def test_flow_user_already_configured(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} DOMAIN, 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"
# Test flow with duplicate config # Test flow with duplicate config
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.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -23,7 +23,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=LIGHT_AND_SIGNAL_SERVICE_INFO, data=LIGHT_AND_SIGNAL_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(
"homeassistant.components.qingping.async_setup_entry", return_value=True "homeassistant.components.qingping.async_setup_entry", return_value=True
@ -31,7 +31,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == "Motion & Light EEFF" assert result2["title"] == "Motion & Light 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"
@ -50,7 +50,7 @@ async def test_async_step_bluetooth_not_enough_info_at_start(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NO_DATA_SERVICE_INFO, data=NO_DATA_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(
"homeassistant.components.qingping.async_setup_entry", return_value=True "homeassistant.components.qingping.async_setup_entry", return_value=True
@ -58,7 +58,7 @@ async def test_async_step_bluetooth_not_enough_info_at_start(
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"] == "Qingping Motion & Light" assert result2["title"] == "Qingping Motion & Light"
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"
@ -75,7 +75,7 @@ async def test_async_step_bluetooth_not_qingping(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_QINGPING_SERVICE_INFO, data=NOT_QINGPING_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -85,7 +85,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"
@ -99,7 +99,7 @@ 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( with patch(
"homeassistant.components.qingping.async_setup_entry", return_value=True "homeassistant.components.qingping.async_setup_entry", return_value=True
@ -108,7 +108,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
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"] == "Motion & Light EEFF" assert result2["title"] == "Motion & Light 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"
@ -124,7 +124,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(
@ -140,7 +140,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"
@ -162,7 +162,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"
@ -179,7 +179,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=LIGHT_AND_SIGNAL_SERVICE_INFO, data=LIGHT_AND_SIGNAL_SERVICE_INFO,
) )
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_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=LIGHT_AND_SIGNAL_SERVICE_INFO, data=LIGHT_AND_SIGNAL_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(
@ -198,7 +198,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=LIGHT_AND_SIGNAL_SERVICE_INFO, data=LIGHT_AND_SIGNAL_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"
@ -211,7 +211,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=LIGHT_AND_SIGNAL_SERVICE_INFO, data=LIGHT_AND_SIGNAL_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(
@ -222,7 +222,7 @@ 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( with patch(
"homeassistant.components.qingping.async_setup_entry", return_value=True "homeassistant.components.qingping.async_setup_entry", return_value=True
@ -231,7 +231,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
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"] == "Motion & Light EEFF" assert result2["title"] == "Motion & Light 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"

View file

@ -5,7 +5,7 @@ from unittest.mock import MagicMock
import pytest import pytest
from requests.exceptions import ConnectTimeout from requests.exceptions import ConnectTimeout
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.qnap import const from homeassistant.components.qnap import const
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -16,6 +16,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 .conftest import TEST_HOST, TEST_PASSWORD, TEST_USERNAME from .conftest import TEST_HOST, TEST_PASSWORD, TEST_USERNAME
@ -35,7 +36,7 @@ async def test_config_flow(hass: HomeAssistant, qnap_connect: MagicMock) -> None
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"] == {}
@ -45,7 +46,7 @@ async def test_config_flow(hass: HomeAssistant, qnap_connect: MagicMock) -> None
STANDARD_CONFIG, STANDARD_CONFIG,
) )
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": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -55,7 +56,7 @@ async def test_config_flow(hass: HomeAssistant, qnap_connect: MagicMock) -> None
STANDARD_CONFIG, STANDARD_CONFIG,
) )
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": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -65,7 +66,7 @@ async def test_config_flow(hass: HomeAssistant, qnap_connect: MagicMock) -> None
STANDARD_CONFIG, STANDARD_CONFIG,
) )
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": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -75,7 +76,7 @@ async def test_config_flow(hass: HomeAssistant, qnap_connect: MagicMock) -> None
STANDARD_CONFIG, STANDARD_CONFIG,
) )
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Test NAS name" assert result["title"] == "Test NAS name"
assert result["data"] == { assert result["data"] == {
CONF_HOST: "1.2.3.4", CONF_HOST: "1.2.3.4",

View file

@ -5,12 +5,13 @@ from unittest.mock import MagicMock, patch
from aioqsw.const import API_MAC_ADDR, API_PRODUCT, API_RESULT from aioqsw.const import API_MAC_ADDR, API_PRODUCT, API_RESULT
from aioqsw.exceptions import LoginError, QswError from aioqsw.exceptions import LoginError, QswError
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.qnap_qsw.const import DOMAIN from homeassistant.components.qnap_qsw.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_URL, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from .util import CONFIG, LIVE_MOCK, SYSTEM_BOARD_MOCK, USERS_LOGIN_MOCK from .util import CONFIG, LIVE_MOCK, SYSTEM_BOARD_MOCK, USERS_LOGIN_MOCK
@ -53,7 +54,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"] == {}
@ -67,7 +68,7 @@ async def test_form(hass: HomeAssistant) -> None:
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED assert entry.state is ConfigEntryState.LOADED
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert ( assert (
result["title"] result["title"]
== f"QNAP {SYSTEM_BOARD_MOCK[API_RESULT][API_PRODUCT]} {SYSTEM_BOARD_MOCK[API_RESULT][API_MAC_ADDR]}" == f"QNAP {SYSTEM_BOARD_MOCK[API_RESULT][API_PRODUCT]} {SYSTEM_BOARD_MOCK[API_RESULT][API_MAC_ADDR]}"
@ -164,7 +165,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"] == "discovered_connection" assert result["step_id"] == "discovered_connection"
with ( with (
@ -216,7 +217,7 @@ async def test_dhcp_flow_error(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"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -233,7 +234,7 @@ async def test_dhcp_connection_error(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"] == "discovered_connection" assert result["step_id"] == "discovered_connection"
with patch( with patch(
@ -264,7 +265,7 @@ async def test_dhcp_login_error(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"] == "discovered_connection" assert result["step_id"] == "discovered_connection"
with patch( with patch(

View file

@ -84,7 +84,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 not result["errors"] assert not result["errors"]
with patch( with patch(
@ -100,7 +100,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_TITLE assert result2["title"] == TEST_TITLE
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -127,7 +127,7 @@ async def test_form_cannot_connect(
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(
@ -142,7 +142,7 @@ async def test_form_cannot_connect(
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": base_value} assert result2["errors"] == {"base": base_value}
@ -151,7 +151,7 @@ async def test_form_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 not result["errors"] assert not result["errors"]
with patch( with patch(
@ -166,7 +166,7 @@ async def test_form_unknown_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"}
@ -177,7 +177,7 @@ async def test_zeroconf_discovery(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=ZEROCONF_DATA DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=ZEROCONF_DATA
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
with patch( with patch(
@ -193,7 +193,7 @@ async def test_zeroconf_discovery(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_TITLE assert result2["title"] == TEST_TITLE
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: TEST_NAME + ".local", CONF_HOST: TEST_NAME + ".local",
@ -207,5 +207,5 @@ async def test_zeroconf_discovery(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=ZEROCONF_DATA DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=ZEROCONF_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -35,7 +35,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_cannot_connect( async def test_cannot_connect(
@ -50,7 +50,7 @@ async def test_cannot_connect(
data=MOCK_USER_INPUT, data=MOCK_USER_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": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -64,7 +64,7 @@ async def test_invalid_auth(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=MOCK_USER_INPUT DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=MOCK_USER_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": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -81,7 +81,7 @@ async def test_wrong_app(hass: HomeAssistant) -> None:
data={CONF_URL: URL, CONF_VERIFY_SSL: False}, data={CONF_URL: URL, CONF_VERIFY_SSL: False},
) )
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"
@ -98,7 +98,7 @@ async def test_zero_conf_failure(hass: HomeAssistant) -> None:
data={CONF_URL: URL, CONF_VERIFY_SSL: False}, data={CONF_URL: URL, CONF_VERIFY_SSL: False},
) )
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"
@ -115,7 +115,7 @@ async def test_unknown_error(hass: HomeAssistant) -> None:
data=MOCK_USER_INPUT, data=MOCK_USER_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": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -132,7 +132,7 @@ async def test_zero_conf(hass: HomeAssistant) -> None:
data={CONF_URL: URL, CONF_VERIFY_SSL: False}, data={CONF_URL: URL, CONF_VERIFY_SSL: False},
) )
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
@ -153,14 +153,14 @@ async def test_full_reauth_flow_implementation(
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"
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
with patch_async_setup_entry() as mock_setup_entry: with patch_async_setup_entry() as mock_setup_entry:
@ -169,7 +169,7 @@ async def test_full_reauth_flow_implementation(
) )
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 == CONF_DATA | {CONF_API_KEY: "test-api-key-reauth"} assert entry.data == CONF_DATA | {CONF_API_KEY: "test-api-key-reauth"}
@ -188,7 +188,7 @@ async def test_full_user_flow_implementation(
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"
with patch_async_setup_entry(): with patch_async_setup_entry():
@ -197,7 +197,7 @@ async def test_full_user_flow_implementation(
user_input=MOCK_USER_INPUT, user_input=MOCK_USER_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
assert result["data"][CONF_URL] == "http://192.168.1.189:7887/test" assert result["data"][CONF_URL] == "http://192.168.1.189:7887/test"

View file

@ -15,7 +15,7 @@ async def test_full_user_flow(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": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") is None assert result.get("errors") is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -23,7 +23,7 @@ async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock)
user_input={}, user_input={},
) )
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Radio Browser" assert result2.get("title") == "Radio Browser"
assert result2.get("data") == {} assert result2.get("data") == {}
@ -42,7 +42,7 @@ async def test_already_configured(
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"
@ -54,7 +54,7 @@ async def test_onboarding_flow(
DOMAIN, context={"source": "onboarding"} DOMAIN, context={"source": "onboarding"}
) )
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "Radio Browser" assert result.get("title") == "Radio Browser"
assert result.get("data") == {} assert result.get("data") == {}

View file

@ -5,11 +5,12 @@ from unittest.mock import MagicMock, patch
from radiotherm import CommonThermostat from radiotherm import CommonThermostat
from radiotherm.validate import RadiothermTstatError from radiotherm.validate import RadiothermTstatError
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.radiotherm.const import DOMAIN from homeassistant.components.radiotherm.const import DOMAIN
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 tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -51,7 +52,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"] == "My Name" assert result2["title"] == "My Name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -76,7 +77,7 @@ async def test_form_unknown_error(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"}
@ -97,7 +98,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"] == {CONF_HOST: "cannot_connect"} assert result2["errors"] == {CONF_HOST: "cannot_connect"}
@ -119,7 +120,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None:
) )
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"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -137,7 +138,7 @@ async def test_dhcp_can_confirm(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"] == "My Name" assert result2["title"] == "My Name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -163,7 +164,7 @@ async def test_dhcp_fails_to_connect(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"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -192,7 +193,7 @@ async def test_dhcp_already_exists(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"
@ -209,7 +210,7 @@ async def test_user_unique_id_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -230,5 +231,5 @@ async def test_user_unique_id_already_exists(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"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -61,7 +61,7 @@ async def complete_flow(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.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
assert not result.get("errors") assert not result.get("errors")
assert "flow_id" in result assert "flow_id" in result
@ -165,7 +165,7 @@ async def test_multiple_config_entries(
responses.extend(config_flow_responses) responses.extend(config_flow_responses)
result = await complete_flow(hass) result = await complete_flow(hass)
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert dict(result.get("result").data) == expected_config_entry assert dict(result.get("result").data) == expected_config_entry
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
@ -241,7 +241,7 @@ async def test_duplicate_config_entries(
result = await complete_flow(hass) result = await complete_flow(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
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 dict(config_entry.data) == expected_config_entry_data assert dict(config_entry.data) == expected_config_entry_data
@ -261,7 +261,7 @@ async def test_controller_cannot_connect(
) )
result = await complete_flow(hass) result = await complete_flow(hass)
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"}
@ -279,7 +279,7 @@ async def test_controller_timeout(
side_effect=TimeoutError, side_effect=TimeoutError,
): ):
result = await complete_flow(hass) result = await complete_flow(hass)
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": "timeout_connect"} assert result.get("errors") == {"base": "timeout_connect"}
@ -303,14 +303,14 @@ async def test_options_flow(hass: HomeAssistant, mock_setup: Mock) -> None:
# Initiate the options flow # Initiate the options flow
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.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "init" assert result.get("step_id") == "init"
# Change the default duration # Change the default duration
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={ATTR_DURATION: 5} result["flow_id"], user_input={ATTR_DURATION: 5}
) )
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert config_entry.options == { assert config_entry.options == {
ATTR_DURATION: 5, ATTR_DURATION: 5,
} }

View file

@ -22,7 +22,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 (
@ -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"] == "abcdef" assert result2["title"] == "abcdef"
assert result2["data"] == { assert result2["data"] == {
CONF_TYPE: TYPE_EAGLE_200, CONF_TYPE: TYPE_EAGLE_200,
@ -76,7 +76,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"}
@ -99,5 +99,5 @@ 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"}

View file

@ -6,11 +6,11 @@ from aioraven.device import RAVEnConnectionError
import pytest import pytest
import serial.tools.list_ports import serial.tools.list_ports
from homeassistant import data_entry_flow
from homeassistant.components.rainforest_raven.const import DOMAIN from homeassistant.components.rainforest_raven.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_MAC, CONF_SOURCE from homeassistant.const import CONF_DEVICE, CONF_MAC, CONF_SOURCE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import create_mock_device from . import create_mock_device
from .const import DEVICE_NAME, DISCOVERY_INFO, METER_LIST from .const import DEVICE_NAME, DISCOVERY_INFO, METER_LIST
@ -74,7 +74,7 @@ async def test_flow_usb(hass: HomeAssistant, mock_comports, mock_device):
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert not result.get("errors") assert not result.get("errors")
assert result.get("flow_id") assert result.get("flow_id")
assert result.get("step_id") == "meters" assert result.get("step_id") == "meters"
@ -83,7 +83,7 @@ async def test_flow_usb(hass: HomeAssistant, mock_comports, mock_device):
result["flow_id"], user_input={CONF_MAC: [METER_LIST.meter_mac_ids[0].hex()]} result["flow_id"], user_input={CONF_MAC: [METER_LIST.meter_mac_ids[0].hex()]}
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
async def test_flow_usb_cannot_connect( async def test_flow_usb_cannot_connect(
@ -94,7 +94,7 @@ async def test_flow_usb_cannot_connect(
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "cannot_connect" assert result.get("reason") == "cannot_connect"
@ -106,7 +106,7 @@ async def test_flow_usb_timeout_connect(
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "timeout_connect" assert result.get("reason") == "timeout_connect"
@ -118,7 +118,7 @@ async def test_flow_usb_comm_error(
DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO DOMAIN, context={CONF_SOURCE: SOURCE_USB}, data=DISCOVERY_INFO
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "cannot_connect" assert result.get("reason") == "cannot_connect"
@ -129,7 +129,7 @@ async def test_flow_user(hass: HomeAssistant, mock_comports, mock_device):
context={CONF_SOURCE: SOURCE_USER}, context={CONF_SOURCE: SOURCE_USER},
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert not result.get("errors") assert not result.get("errors")
assert result.get("flow_id") assert result.get("flow_id")
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -141,7 +141,7 @@ async def test_flow_user(hass: HomeAssistant, mock_comports, mock_device):
}, },
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert not result.get("errors") assert not result.get("errors")
assert result.get("flow_id") assert result.get("flow_id")
assert result.get("step_id") == "meters" assert result.get("step_id") == "meters"
@ -150,7 +150,7 @@ async def test_flow_user(hass: HomeAssistant, mock_comports, mock_device):
result["flow_id"], user_input={CONF_MAC: [METER_LIST.meter_mac_ids[0].hex()]} result["flow_id"], user_input={CONF_MAC: [METER_LIST.meter_mac_ids[0].hex()]}
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
async def test_flow_user_no_available_devices(hass: HomeAssistant, mock_comports): async def test_flow_user_no_available_devices(hass: HomeAssistant, mock_comports):
@ -165,7 +165,7 @@ async def test_flow_user_no_available_devices(hass: HomeAssistant, mock_comports
context={CONF_SOURCE: SOURCE_USER}, context={CONF_SOURCE: SOURCE_USER},
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "no_devices_found" assert result.get("reason") == "no_devices_found"
@ -176,7 +176,7 @@ async def test_flow_user_in_progress(hass: HomeAssistant, mock_comports):
context={CONF_SOURCE: SOURCE_USER}, context={CONF_SOURCE: SOURCE_USER},
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert not result.get("errors") assert not result.get("errors")
assert result.get("flow_id") assert result.get("flow_id")
assert result.get("step_id") == "user" assert result.get("step_id") == "user"
@ -186,7 +186,7 @@ async def test_flow_user_in_progress(hass: HomeAssistant, mock_comports):
context={CONF_SOURCE: SOURCE_USER}, context={CONF_SOURCE: SOURCE_USER},
) )
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_in_progress" assert result.get("reason") == "already_in_progress"
@ -202,7 +202,7 @@ async def test_flow_user_cannot_connect(
}, },
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_DEVICE: "cannot_connect"} assert result.get("errors") == {CONF_DEVICE: "cannot_connect"}
@ -218,7 +218,7 @@ async def test_flow_user_timeout_connect(
}, },
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_DEVICE: "timeout_connect"} assert result.get("errors") == {CONF_DEVICE: "timeout_connect"}
@ -234,5 +234,5 @@ async def test_flow_user_comm_error(
}, },
) )
assert result assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_DEVICE: "cannot_connect"} assert result.get("errors") == {CONF_DEVICE: "cannot_connect"}

View file

@ -6,7 +6,7 @@ from unittest.mock import patch
import pytest import pytest
from regenmaschine.errors import RainMachineError from regenmaschine.errors import RainMachineError
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.rainmachine import ( from homeassistant.components.rainmachine import (
CONF_ALLOW_INACTIVE_ZONES_TO_RUN, CONF_ALLOW_INACTIVE_ZONES_TO_RUN,
@ -16,6 +16,7 @@ from homeassistant.components.rainmachine import (
) )
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
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
@ -24,7 +25,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": config_entries.SOURCE_USER}, data=config DOMAIN, context={"source": config_entries.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"
@ -107,7 +108,7 @@ async def test_options_flow(hass: HomeAssistant, config, config_entry) -> None:
): ):
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.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(
@ -118,7 +119,7 @@ async def test_options_flow(hass: HomeAssistant, config, config_entry) -> None:
CONF_ALLOW_INACTIVE_ZONES_TO_RUN: False, CONF_ALLOW_INACTIVE_ZONES_TO_RUN: 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 == {
CONF_DEFAULT_ZONE_RUN_TIME: 600, CONF_DEFAULT_ZONE_RUN_TIME: 600,
CONF_USE_APP_RUN_TIMES: False, CONF_USE_APP_RUN_TIMES: False,
@ -133,7 +134,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=None, 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"
@ -144,7 +145,7 @@ async def test_step_user(hass: HomeAssistant, config, setup_rainmachine) -> None
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=config, data=config,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "12345" assert result["title"] == "12345"
assert result["data"] == { assert result["data"] == {
CONF_IP_ADDRESS: "192.168.1.100", CONF_IP_ADDRESS: "192.168.1.100",
@ -179,7 +180,7 @@ async def test_step_homekit_zeroconf_ip_already_exists(
), ),
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -207,7 +208,7 @@ async def test_step_homekit_zeroconf_ip_change(
), ),
) )
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 config_entry.data[CONF_IP_ADDRESS] == "192.168.1.2" assert config_entry.data[CONF_IP_ADDRESS] == "192.168.1.2"
@ -236,7 +237,7 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist(
), ),
) )
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 (
@ -258,7 +259,7 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist(
) )
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"] == "12345" assert result2["title"] == "12345"
assert result2["data"] == { assert result2["data"] == {
CONF_IP_ADDRESS: "192.168.1.100", CONF_IP_ADDRESS: "192.168.1.100",
@ -290,7 +291,7 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(
), ),
) )
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(
@ -310,5 +311,5 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(
), ),
) )
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"

View file

@ -60,14 +60,14 @@ async def test_config_flow(
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"],
{"next_step_id": entity_type}, {"next_step_id": entity_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"] == entity_type assert result["step_id"] == entity_type
with patch( with patch(
@ -82,7 +82,7 @@ async def test_config_flow(
) )
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 random entity" assert result["title"] == "My random entity"
assert result["data"] == {} assert result["data"] == {}
assert result["options"] == { assert result["options"] == {
@ -108,14 +108,14 @@ async def test_wrong_uom(
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"],
{"next_step_id": "sensor"}, {"next_step_id": "sensor"},
) )
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"] == "sensor" assert result["step_id"] == "sensor"
with pytest.raises(Invalid, match="is not a valid unit for device class"): with pytest.raises(Invalid, match="is not a valid unit for device class"):
@ -179,7 +179,7 @@ async def test_options(
config_entry = hass.config_entries.async_entries(DOMAIN)[0] config_entry = hass.config_entries.async_entries(DOMAIN)[0]
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"] == entity_type assert result["step_id"] == entity_type
assert "name" not in result["data_schema"].schema assert "name" not in result["data_schema"].schema
@ -187,7 +187,7 @@ async def test_options(
result["flow_id"], result["flow_id"],
user_input=options_options, user_input=options_options,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"name": "My random", "name": "My random",
"entity_type": entity_type, "entity_type": entity_type,

View file

@ -19,7 +19,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=COMPLETE_SERVICE_INFO, data=COMPLETE_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(
"homeassistant.components.rapt_ble.async_setup_entry", return_value=True "homeassistant.components.rapt_ble.async_setup_entry", return_value=True
@ -27,7 +27,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == "RAPT Pill 0666" assert result2["title"] == "RAPT Pill 0666"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == RAPT_MAC assert result2["result"].unique_id == RAPT_MAC
@ -40,7 +40,7 @@ async def test_async_step_bluetooth_not_rapt(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_RAPT_SERVICE_INFO, data=NOT_RAPT_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -50,7 +50,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"
@ -64,7 +64,7 @@ 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( with patch(
"homeassistant.components.rapt_ble.async_setup_entry", return_value=True "homeassistant.components.rapt_ble.async_setup_entry", return_value=True
@ -73,7 +73,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={"address": RAPT_MAC}, user_input={"address": RAPT_MAC},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "RAPT Pill 0666" assert result2["title"] == "RAPT Pill 0666"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == RAPT_MAC assert result2["result"].unique_id == RAPT_MAC
@ -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(
@ -105,7 +105,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"], result["flow_id"],
user_input={"address": RAPT_MAC}, user_input={"address": RAPT_MAC},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -127,7 +127,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"
@ -144,7 +144,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=COMPLETE_SERVICE_INFO, data=COMPLETE_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -155,7 +155,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=COMPLETE_SERVICE_INFO, data=COMPLETE_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(
@ -163,7 +163,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=COMPLETE_SERVICE_INFO, data=COMPLETE_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"
@ -176,7 +176,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=COMPLETE_SERVICE_INFO, data=COMPLETE_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(
@ -187,7 +187,7 @@ 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( with patch(
"homeassistant.components.rapt_ble.async_setup_entry", return_value=True "homeassistant.components.rapt_ble.async_setup_entry", return_value=True
@ -196,7 +196,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
result["flow_id"], result["flow_id"],
user_input={"address": RAPT_MAC}, user_input={"address": RAPT_MAC},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "RAPT Pill 0666" assert result2["title"] == "RAPT Pill 0666"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == RAPT_MAC assert result2["result"].unique_id == RAPT_MAC

View file

@ -21,7 +21,7 @@ async def test_config_flow(hass: HomeAssistant) -> None:
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Raspberry Pi" assert result["title"] == "Raspberry Pi"
assert result["data"] == {} assert result["data"] == {}
assert result["options"] == {} assert result["options"] == {}
@ -54,6 +54,6 @@ async def test_config_flow_single_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == 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()

View file

@ -18,7 +18,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(
@ -28,7 +28,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") == "11-ZKZ-3" assert result2.get("title") == "11-ZKZ-3"
assert result2.get("data") == {CONF_LICENSE_PLATE: "11ZKZ3"} assert result2.get("data") == {CONF_LICENSE_PLATE: "11ZKZ3"}
@ -45,7 +45,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_rdw_config_flow.vehicle.side_effect = RDWUnknownLicensePlateError mock_rdw_config_flow.vehicle.side_effect = RDWUnknownLicensePlateError
@ -56,7 +56,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") == {"base": "unknown_license_plate"} assert result2.get("errors") == {"base": "unknown_license_plate"}
@ -68,7 +68,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") == "11-ZKZ-3" assert result3.get("title") == "11-ZKZ-3"
assert result3.get("data") == {CONF_LICENSE_PLATE: "11ZKZ3"} assert result3.get("data") == {CONF_LICENSE_PLATE: "11ZKZ3"}
@ -85,5 +85,5 @@ async def test_connection_error(
data={CONF_LICENSE_PLATE: "0001TJ"}, data={CONF_LICENSE_PLATE: "0001TJ"},
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": "cannot_connect"} assert result.get("errors") == {"base": "cannot_connect"}

View file

@ -5,7 +5,6 @@ from unittest.mock import AsyncMock, patch
from aiorecollect.errors import RecollectError from aiorecollect.errors import RecollectError
import pytest import pytest
from homeassistant import data_entry_flow
from homeassistant.components.recollect_waste import ( from homeassistant.components.recollect_waste import (
CONF_PLACE_ID, CONF_PLACE_ID,
CONF_SERVICE_ID, CONF_SERVICE_ID,
@ -14,6 +13,7 @@ from homeassistant.components.recollect_waste import (
from homeassistant.config_entries import SOURCE_USER from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_FRIENDLY_NAME from homeassistant.const import CONF_FRIENDLY_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .conftest import TEST_PLACE_ID, TEST_SERVICE_ID from .conftest import TEST_PLACE_ID, TEST_SERVICE_ID
@ -39,7 +39,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 checking the API key: # Test errors that can arise when checking the API key:
@ -47,13 +47,13 @@ async def test_create_entry(
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["errors"] == get_pickup_events_errors assert result["errors"] == get_pickup_events_errors
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_PLACE_ID}, {TEST_SERVICE_ID}" assert result["title"] == f"{TEST_PLACE_ID}, {TEST_SERVICE_ID}"
assert result["data"] == { assert result["data"] == {
CONF_PLACE_ID: TEST_PLACE_ID, CONF_PLACE_ID: TEST_PLACE_ID,
@ -66,7 +66,7 @@ async def test_duplicate_error(hass: HomeAssistant, config, setup_config_entry)
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"
@ -75,11 +75,11 @@ 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"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_FRIENDLY_NAME: True} result["flow_id"], user_input={CONF_FRIENDLY_NAME: True}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_FRIENDLY_NAME: True} assert config_entry.options == {CONF_FRIENDLY_NAME: True}

View file

@ -2,9 +2,10 @@
from unittest.mock import AsyncMock, patch from unittest.mock import AsyncMock, patch
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.refoss.const import DOMAIN from homeassistant.components.refoss.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import FakeDiscovery, build_base_device_mock from . import FakeDiscovery, build_base_device_mock
@ -33,11 +34,11 @@ async def test_creating_entry_sets_up(
) )
# Confirmation form # Confirmation form
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()
@ -60,10 +61,10 @@ async def test_creating_entry_has_no_devices(
) )
# Confirmation form # Confirmation form
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.ABORT assert result["type"] is FlowResultType.ABORT
await hass.async_block_till_done() await hass.async_block_till_done()

View file

@ -7,7 +7,7 @@ from renault_api.gigya.exceptions import InvalidCredentialsException
from renault_api.kamereon import schemas from renault_api.kamereon import schemas
from renault_api.renault_account import RenaultAccount from renault_api.renault_account import RenaultAccount
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.renault.const import ( from homeassistant.components.renault.const import (
CONF_KAMEREON_ACCOUNT_ID, CONF_KAMEREON_ACCOUNT_ID,
CONF_LOCALE, CONF_LOCALE,
@ -16,6 +16,7 @@ from homeassistant.components.renault.const import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
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 homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from .const import MOCK_CONFIG from .const import MOCK_CONFIG
@ -32,7 +33,7 @@ async def test_config_flow_single_account(
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"] == {}
# Failed credentials # Failed credentials
@ -49,7 +50,7 @@ async def test_config_flow_single_account(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_credentials"} assert result["errors"] == {"base": "invalid_credentials"}
renault_account = AsyncMock() renault_account = AsyncMock()
@ -80,7 +81,7 @@ async def test_config_flow_single_account(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "account_id_1" assert result["title"] == "account_id_1"
assert result["data"][CONF_USERNAME] == "email@test.com" assert result["data"][CONF_USERNAME] == "email@test.com"
assert result["data"][CONF_PASSWORD] == "test" assert result["data"][CONF_PASSWORD] == "test"
@ -97,7 +98,7 @@ async def test_config_flow_no_account(
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"] == {}
# Account list empty # Account list empty
@ -117,7 +118,7 @@ async def test_config_flow_no_account(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "kamereon_no_account" assert result["reason"] == "kamereon_no_account"
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -130,7 +131,7 @@ async def test_config_flow_multiple_accounts(
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"] == {}
renault_account_1 = RenaultAccount( renault_account_1 = RenaultAccount(
@ -160,7 +161,7 @@ async def test_config_flow_multiple_accounts(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "kamereon" assert result["step_id"] == "kamereon"
# Account selected # Account selected
@ -168,7 +169,7 @@ async def test_config_flow_multiple_accounts(
result["flow_id"], result["flow_id"],
user_input={CONF_KAMEREON_ACCOUNT_ID: "account_id_2"}, user_input={CONF_KAMEREON_ACCOUNT_ID: "account_id_2"},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "account_id_2" assert result["title"] == "account_id_2"
assert result["data"][CONF_USERNAME] == "email@test.com" assert result["data"][CONF_USERNAME] == "email@test.com"
assert result["data"][CONF_PASSWORD] == "test" assert result["data"][CONF_PASSWORD] == "test"
@ -188,7 +189,7 @@ async def test_config_flow_duplicate(
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"] == {}
renault_account = RenaultAccount( renault_account = RenaultAccount(
@ -212,7 +213,7 @@ async def test_config_flow_duplicate(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -233,7 +234,7 @@ async def test_reauth(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
data=MOCK_CONFIG, data=MOCK_CONFIG,
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] == {CONF_USERNAME: "email@test.com"} assert result["description_placeholders"] == {CONF_USERNAME: "email@test.com"}
assert result["errors"] == {} assert result["errors"] == {}
@ -247,7 +248,7 @@ async def test_reauth(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
user_input={CONF_PASSWORD: "any"}, user_input={CONF_PASSWORD: "any"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {CONF_USERNAME: "email@test.com"} assert result2["description_placeholders"] == {CONF_USERNAME: "email@test.com"}
assert result2["errors"] == {"base": "invalid_credentials"} assert result2["errors"] == {"base": "invalid_credentials"}
@ -258,5 +259,5 @@ async def test_reauth(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
user_input={CONF_PASSWORD: "any"}, user_input={CONF_PASSWORD: "any"},
) )
assert result3["type"] == data_entry_flow.FlowResultType.ABORT assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"

View file

@ -13,7 +13,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 (
@ -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"] == "Renson" assert result2["title"] == "Renson"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -59,7 +59,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"}
@ -80,5 +80,5 @@ async def test_form_unknown(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -8,7 +8,7 @@ from unittest.mock import AsyncMock, MagicMock, call
import pytest import pytest
from reolink_aio.exceptions import ApiError, CredentialsInvalidError, ReolinkError from reolink_aio.exceptions import ApiError, CredentialsInvalidError, ReolinkError
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.reolink import DEVICE_UPDATE_INTERVAL, const from homeassistant.components.reolink import DEVICE_UPDATE_INTERVAL, const
from homeassistant.components.reolink.config_flow import DEFAULT_PROTOCOL from homeassistant.components.reolink.config_flow import DEFAULT_PROTOCOL
@ -23,6 +23,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 homeassistant.helpers.device_registry import format_mac from homeassistant.helpers.device_registry import format_mac
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -53,7 +54,7 @@ async def test_config_flow_manual_success(
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"] == {}
@ -66,7 +67,7 @@ async def test_config_flow_manual_success(
}, },
) )
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME assert result["title"] == TEST_NVR_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -88,7 +89,7 @@ async def test_config_flow_errors(
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"] == {}
@ -103,7 +104,7 @@ async def test_config_flow_errors(
}, },
) )
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"] == {CONF_USERNAME: "not_admin"} assert result["errors"] == {CONF_USERNAME: "not_admin"}
@ -119,7 +120,7 @@ async def test_config_flow_errors(
}, },
) )
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"] == {CONF_HOST: "cannot_connect"} assert result["errors"] == {CONF_HOST: "cannot_connect"}
@ -133,7 +134,7 @@ async def test_config_flow_errors(
}, },
) )
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": "webhook_exception"} assert result["errors"] == {"base": "webhook_exception"}
@ -149,7 +150,7 @@ async def test_config_flow_errors(
}, },
) )
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"] == {CONF_HOST: "unknown"} assert result["errors"] == {CONF_HOST: "unknown"}
@ -163,7 +164,7 @@ async def test_config_flow_errors(
}, },
) )
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"] == {CONF_HOST: "invalid_auth"} assert result["errors"] == {CONF_HOST: "invalid_auth"}
@ -177,7 +178,7 @@ async def test_config_flow_errors(
}, },
) )
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"] == {CONF_HOST: "api_error"} assert result["errors"] == {CONF_HOST: "api_error"}
@ -193,7 +194,7 @@ async def test_config_flow_errors(
}, },
) )
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME assert result["title"] == TEST_NVR_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -231,7 +232,7 @@ async def test_options_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) ->
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(
@ -239,7 +240,7 @@ async def test_options_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) ->
user_input={CONF_PROTOCOL: "rtmp"}, user_input={CONF_PROTOCOL: "rtmp"},
) )
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_PROTOCOL: "rtmp", CONF_PROTOCOL: "rtmp",
} }
@ -270,7 +271,7 @@ async def test_change_connection_settings(
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"] == {}
@ -283,7 +284,7 @@ async def test_change_connection_settings(
}, },
) )
assert result["type"] is data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == TEST_HOST2 assert config_entry.data[CONF_HOST] == TEST_HOST2
assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2 assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2
@ -323,7 +324,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
data=config_entry.data, data=config_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(
@ -331,7 +332,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> 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"
assert result["errors"] == {} assert result["errors"] == {}
@ -343,7 +344,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
}, },
) )
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 config_entry.data[CONF_HOST] == TEST_HOST assert config_entry.data[CONF_HOST] == TEST_HOST
assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2 assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2
@ -362,7 +363,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) -> No
const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_data const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_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"] == {} assert result["errors"] == {}
@ -374,7 +375,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) -> No
}, },
) )
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME assert result["title"] == TEST_NVR_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -489,7 +490,7 @@ async def test_dhcp_ip_update(
assert reolink_connect_class.call_args_list == expected_calls assert reolink_connect_class.call_args_list == expected_calls
assert result["type"] is data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()

View file

@ -6,10 +6,11 @@ from unittest.mock import MagicMock, patch, sentinel
from RFXtrx import RFXtrxTransportError from RFXtrx import RFXtrxTransportError
import serial.tools.list_ports import serial.tools.list_ports
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.rfxtrx import DOMAIN, config_flow from homeassistant.components.rfxtrx import DOMAIN, config_flow
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -284,7 +285,7 @@ async def test_options_global(hass: HomeAssistant) -> None:
user_input={"automatic_add": True, "protocols": SOME_PROTOCOLS}, user_input={"automatic_add": True, "protocols": SOME_PROTOCOLS},
) )
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()
@ -319,7 +320,7 @@ async def test_no_protocols(hass: HomeAssistant) -> None:
user_input={"automatic_add": False, "protocols": []}, user_input={"automatic_add": False, "protocols": []},
) )
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()
@ -374,7 +375,7 @@ async def test_options_add_device(hass: HomeAssistant) -> None:
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
await hass.async_block_till_done() await hass.async_block_till_done()
@ -528,7 +529,7 @@ async def test_options_replace_sensor_device(hass: HomeAssistant) -> None:
}, },
) )
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()
@ -661,7 +662,7 @@ async def test_options_replace_control_device(hass: HomeAssistant) -> None:
}, },
) )
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()
@ -742,7 +743,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
}, },
) )
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()
@ -786,7 +787,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
}, },
) )
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()
@ -869,7 +870,7 @@ async def test_options_configure_rfy_cover_device(hass: HomeAssistant) -> None:
}, },
) )
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()

View file

@ -15,7 +15,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(
@ -28,7 +28,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"] == "Rhasspy" assert result2["title"] == "Rhasspy"
assert result2["data"] == {} assert result2["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -41,5 +41,5 @@ async def test_single_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.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"

View file

@ -28,7 +28,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": 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"
# Test errors that can arise: # Test errors that can arise:
@ -39,7 +39,7 @@ async def test_create_entry(
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"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == errors assert result["errors"] == errors
@ -47,7 +47,7 @@ async def test_create_entry(
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"] == 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_USERNAME: TEST_USERNAME, CONF_USERNAME: TEST_USERNAME,
@ -60,7 +60,7 @@ async def test_duplicate_error(hass: HomeAssistant, config, setup_config_entry)
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=config DOMAIN, context={"source": config_entries.SOURCE_USER}, data=config
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -75,6 +75,6 @@ async def test_step_reauth(
result["flow_id"], result["flow_id"],
user_input={CONF_PASSWORD: "new_password"}, user_input={CONF_PASSWORD: "new_password"},
) )
assert result["type"] == 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

View file

@ -76,7 +76,7 @@ async def test_form_2fa(
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"] == {}
mock_ring_auth.fetch_token.side_effect = ring_doorbell.Requires2FAError mock_ring_auth.fetch_token.side_effect = ring_doorbell.Requires2FAError
@ -92,7 +92,7 @@ async def test_form_2fa(
"foo@bar.com", "fake-password", None "foo@bar.com", "fake-password", None
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
mock_ring_auth.fetch_token.reset_mock(side_effect=True) mock_ring_auth.fetch_token.reset_mock(side_effect=True)
mock_ring_auth.fetch_token.return_value = "new-foobar" mock_ring_auth.fetch_token.return_value = "new-foobar"
@ -104,7 +104,7 @@ async def test_form_2fa(
mock_ring_auth.fetch_token.assert_called_once_with( mock_ring_auth.fetch_token.assert_called_once_with(
"foo@bar.com", "fake-password", "123456" "foo@bar.com", "fake-password", "123456"
) )
assert result3["type"] == FlowResultType.CREATE_ENTRY assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "foo@bar.com" assert result3["title"] == "foo@bar.com"
assert result3["data"] == { assert result3["data"] == {
"username": "foo@bar.com", "username": "foo@bar.com",
@ -139,7 +139,7 @@ async def test_reauth(
mock_ring_auth.fetch_token.assert_called_once_with( mock_ring_auth.fetch_token.assert_called_once_with(
"foo@bar.com", "other_fake_password", None "foo@bar.com", "other_fake_password", None
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
mock_ring_auth.fetch_token.reset_mock(side_effect=True) mock_ring_auth.fetch_token.reset_mock(side_effect=True)
mock_ring_auth.fetch_token.return_value = "new-foobar" mock_ring_auth.fetch_token.return_value = "new-foobar"
@ -151,7 +151,7 @@ async def test_reauth(
mock_ring_auth.fetch_token.assert_called_once_with( mock_ring_auth.fetch_token.assert_called_once_with(
"foo@bar.com", "other_fake_password", "123456" "foo@bar.com", "other_fake_password", "123456"
) )
assert result3["type"] == FlowResultType.ABORT assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"
assert mock_added_config_entry.data == { assert mock_added_config_entry.data == {
"username": "foo@bar.com", "username": "foo@bar.com",
@ -197,7 +197,7 @@ async def test_reauth_error(
mock_ring_auth.fetch_token.assert_called_once_with( mock_ring_auth.fetch_token.assert_called_once_with(
"foo@bar.com", "error_fake_password", None "foo@bar.com", "error_fake_password", None
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": errors_msg} assert result2["errors"] == {"base": errors_msg}
# Now test reauth can go on to succeed # Now test reauth can go on to succeed
@ -213,7 +213,7 @@ async def test_reauth_error(
mock_ring_auth.fetch_token.assert_called_once_with( mock_ring_auth.fetch_token.assert_called_once_with(
"foo@bar.com", "other_fake_password", None "foo@bar.com", "other_fake_password", None
) )
assert result3["type"] == FlowResultType.ABORT assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"
assert mock_added_config_entry.data == { assert mock_added_config_entry.data == {
"username": "foo@bar.com", "username": "foo@bar.com",

View file

@ -57,13 +57,13 @@ async def test_cloud_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.MENU assert result["type"] is FlowResultType.MENU
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"next_step_id": "cloud"} result["flow_id"], {"next_step_id": "cloud"}
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {} assert result2["errors"] == {}
with ( with (
@ -88,7 +88,7 @@ async def test_cloud_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"] == TEST_CLOUD_DATA assert result3["data"] == TEST_CLOUD_DATA
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -120,7 +120,7 @@ async def test_cloud_error(hass: HomeAssistant, login_with_error, error) -> None
) )
mock_close.assert_awaited_once() mock_close.assert_awaited_once()
assert result3["type"] == FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": error} assert result3["errors"] == {"base": error}
@ -146,7 +146,7 @@ async def test_form_cloud_already_exists(hass: HomeAssistant) -> None:
result2["flow_id"], TEST_CLOUD_DATA result2["flow_id"], TEST_CLOUD_DATA
) )
assert result3["type"] == FlowResultType.ABORT assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "already_configured" assert result3["reason"] == "already_configured"
@ -236,13 +236,13 @@ async def test_local_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.MENU assert result["type"] is FlowResultType.MENU
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"next_step_id": "local"} result["flow_id"], {"next_step_id": "local"}
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {} assert result2["errors"] == {}
with ( with (
@ -272,7 +272,7 @@ async def test_local_form(hass: HomeAssistant) -> None:
"type": "local", "type": "local",
CONF_COMMUNICATION_DELAY: 0, CONF_COMMUNICATION_DELAY: 0,
} }
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"] == expected_data assert result3["data"] == expected_data
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -300,7 +300,7 @@ async def test_local_error(hass: HomeAssistant, connect_with_error, error) -> No
result2["flow_id"], TEST_LOCAL_DATA result2["flow_id"], TEST_LOCAL_DATA
) )
assert result3["type"] == FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": error} assert result3["errors"] == {"base": error}
@ -339,7 +339,7 @@ async def test_form_local_already_exists(hass: HomeAssistant) -> None:
result2["flow_id"], TEST_LOCAL_DATA result2["flow_id"], TEST_LOCAL_DATA
) )
assert result3["type"] == FlowResultType.ABORT assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "already_configured" assert result3["reason"] == "already_configured"
@ -355,14 +355,14 @@ async def test_options_flow(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"] == 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"], result["flow_id"],
user_input=TEST_OPTIONS, user_input=TEST_OPTIONS,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "risco_to_ha" assert result["step_id"] == "risco_to_ha"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -370,7 +370,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
user_input=TEST_RISCO_TO_HA, user_input=TEST_RISCO_TO_HA,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ha_to_risco" assert result["step_id"] == "ha_to_risco"
with patch("homeassistant.components.risco.async_setup_entry", return_value=True): with patch("homeassistant.components.risco.async_setup_entry", return_value=True):
@ -379,7 +379,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
user_input=TEST_HA_TO_RISCO, user_input=TEST_HA_TO_RISCO,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == { assert entry.options == {
**TEST_OPTIONS, **TEST_OPTIONS,
"risco_states_to_ha": TEST_RISCO_TO_HA, "risco_states_to_ha": TEST_RISCO_TO_HA,

View file

@ -33,7 +33,7 @@ async def test_config_flow_success(
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"
with patch( with patch(
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code" "homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
@ -42,7 +42,7 @@ async def test_config_flow_success(
result["flow_id"], {CONF_USERNAME: USER_EMAIL} result["flow_id"], {CONF_USERNAME: USER_EMAIL}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "code" assert result["step_id"] == "code"
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -53,7 +53,7 @@ async def test_config_flow_success(
result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"} result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == USER_EMAIL assert result["title"] == USER_EMAIL
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
assert result["result"] assert result["result"]
@ -86,7 +86,7 @@ async def test_config_flow_failures_request_code(
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"
with patch( with patch(
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code", "homeassistant.components.roborock.config_flow.RoborockApiClient.request_code",
@ -95,7 +95,7 @@ async def test_config_flow_failures_request_code(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_USERNAME: USER_EMAIL} result["flow_id"], {CONF_USERNAME: USER_EMAIL}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == request_code_errors assert result["errors"] == request_code_errors
# Recover from error # Recover from error
with patch( with patch(
@ -105,7 +105,7 @@ async def test_config_flow_failures_request_code(
result["flow_id"], {CONF_USERNAME: USER_EMAIL} result["flow_id"], {CONF_USERNAME: USER_EMAIL}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "code" assert result["step_id"] == "code"
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -116,7 +116,7 @@ async def test_config_flow_failures_request_code(
result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"} result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == USER_EMAIL assert result["title"] == USER_EMAIL
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
assert result["result"] assert result["result"]
@ -147,7 +147,7 @@ async def test_config_flow_failures_code_login(
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"
with patch( with patch(
"homeassistant.components.roborock.config_flow.RoborockApiClient.request_code" "homeassistant.components.roborock.config_flow.RoborockApiClient.request_code"
@ -156,7 +156,7 @@ async def test_config_flow_failures_code_login(
result["flow_id"], {CONF_USERNAME: USER_EMAIL} result["flow_id"], {CONF_USERNAME: USER_EMAIL}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "code" assert result["step_id"] == "code"
assert result["errors"] == {} assert result["errors"] == {}
# Raise exception for invalid code # Raise exception for invalid code
@ -167,7 +167,7 @@ async def test_config_flow_failures_code_login(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"} result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == code_login_errors assert result["errors"] == code_login_errors
with patch( with patch(
"homeassistant.components.roborock.config_flow.RoborockApiClient.code_login", "homeassistant.components.roborock.config_flow.RoborockApiClient.code_login",
@ -177,7 +177,7 @@ async def test_config_flow_failures_code_login(
result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"} result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == USER_EMAIL assert result["title"] == USER_EMAIL
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
assert result["result"] assert result["result"]
@ -205,7 +205,7 @@ async def test_reauth_flow(
) )
# Enter a new code # Enter a new code
assert result["step_id"] == "code" assert result["step_id"] == "code"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
new_user_data = deepcopy(USER_DATA) new_user_data = deepcopy(USER_DATA)
new_user_data.rriot.s = "new_password_hash" new_user_data.rriot.s = "new_password_hash"
with patch( with patch(
@ -215,6 +215,6 @@ async def test_reauth_flow(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"} result["flow_id"], user_input={CONF_ENTRY_CODE: "123456"}
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"
assert mock_roborock_entry.data["user_data"]["rriot"]["s"] == "new_password_hash" assert mock_roborock_entry.data["user_data"]["rriot"]["s"] == "new_password_hash"

View file

@ -37,7 +37,7 @@ async def test_duplicate_error(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
user_input = {CONF_HOST: mock_config_entry.data[CONF_HOST]} user_input = {CONF_HOST: mock_config_entry.data[CONF_HOST]}
@ -45,7 +45,7 @@ async def test_duplicate_error(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
discovery_info = dataclasses.replace(MOCK_SSDP_DISCOVERY_INFO) discovery_info = dataclasses.replace(MOCK_SSDP_DISCOVERY_INFO)
@ -53,7 +53,7 @@ async def test_duplicate_error(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -66,7 +66,7 @@ async def test_form(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER} DOMAIN, context={CONF_SOURCE: SOURCE_USER}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
user_input = {CONF_HOST: HOST} user_input = {CONF_HOST: HOST}
@ -75,7 +75,7 @@ async def test_form(
) )
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 Roku 3" assert result["title"] == "My Roku 3"
assert "data" in result assert "data" in result
@ -99,7 +99,7 @@ async def test_form_cannot_connect(
flow_id=result["flow_id"], user_input={CONF_HOST: HOST} flow_id=result["flow_id"], user_input={CONF_HOST: HOST}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -118,7 +118,7 @@ async def test_form_unknown_error(
flow_id=result["flow_id"], user_input=user_input flow_id=result["flow_id"], user_input=user_input
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -135,7 +135,7 @@ async def test_homekit_cannot_connect(
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"
@ -152,7 +152,7 @@ async def test_homekit_unknown_error(
data=discovery_info, data=discovery_info,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -168,7 +168,7 @@ async def test_homekit_discovery(
DOMAIN, context={CONF_SOURCE: SOURCE_HOMEKIT}, data=discovery_info DOMAIN, context={CONF_SOURCE: SOURCE_HOMEKIT}, 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"
assert result["description_placeholders"] == {CONF_NAME: NAME_ROKUTV} assert result["description_placeholders"] == {CONF_NAME: NAME_ROKUTV}
@ -177,7 +177,7 @@ async def test_homekit_discovery(
) )
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"] == NAME_ROKUTV assert result["title"] == NAME_ROKUTV
assert "data" in result assert "data" in result
@ -190,7 +190,7 @@ async def test_homekit_discovery(
DOMAIN, context={CONF_SOURCE: SOURCE_HOMEKIT}, data=discovery_info DOMAIN, context={CONF_SOURCE: SOURCE_HOMEKIT}, data=discovery_info
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -207,7 +207,7 @@ async def test_ssdp_cannot_connect(
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"
@ -224,7 +224,7 @@ async def test_ssdp_unknown_error(
data=discovery_info, data=discovery_info,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -239,7 +239,7 @@ async def test_ssdp_discovery(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info DOMAIN, context={CONF_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"
assert result["description_placeholders"] == {CONF_NAME: UPNP_FRIENDLY_NAME} assert result["description_placeholders"] == {CONF_NAME: UPNP_FRIENDLY_NAME}
@ -248,7 +248,7 @@ async def test_ssdp_discovery(
) )
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"] == UPNP_FRIENDLY_NAME assert result["title"] == UPNP_FRIENDLY_NAME
assert result["data"] assert result["data"]

View file

@ -5,11 +5,12 @@ from unittest.mock import Mock, PropertyMock, patch
from romy import RomyRobot from romy import RomyRobot
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.romy.const import DOMAIN from homeassistant.components.romy.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PASSWORD from homeassistant.const import CONF_HOST, CONF_PASSWORD
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
def _create_mocked_romy( def _create_mocked_romy(
@ -56,7 +57,7 @@ async def test_show_user_form_robot_is_offline_and_locked(hass: HomeAssistant) -
assert result1["errors"].get("host") == "cannot_connect" assert result1["errors"].get("host") == "cannot_connect"
assert result1["step_id"] == "user" assert result1["step_id"] == "user"
assert result1["type"] == data_entry_flow.FlowResultType.FORM assert result1["type"] is FlowResultType.FORM
# Robot is locked # Robot is locked
with patch( with patch(
@ -68,7 +69,7 @@ async def test_show_user_form_robot_is_offline_and_locked(hass: HomeAssistant) -
) )
assert result2["step_id"] == "password" assert result2["step_id"] == "password"
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
# Robot is initialized and unlocked # Robot is initialized and unlocked
with patch( with patch(
@ -80,7 +81,7 @@ async def test_show_user_form_robot_is_offline_and_locked(hass: HomeAssistant) -
) )
assert "errors" not in result3 assert "errors" not in result3
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result3["type"] is FlowResultType.CREATE_ENTRY
async def test_show_user_form_robot_unlock_with_password(hass: HomeAssistant) -> None: async def test_show_user_form_robot_unlock_with_password(hass: HomeAssistant) -> None:
@ -106,7 +107,7 @@ async def test_show_user_form_robot_unlock_with_password(hass: HomeAssistant) ->
assert result2["errors"] == {"password": "invalid_auth"} assert result2["errors"] == {"password": "invalid_auth"}
assert result2["step_id"] == "password" assert result2["step_id"] == "password"
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.romy.config_flow.romy.create_romy", "homeassistant.components.romy.config_flow.romy.create_romy",
@ -118,7 +119,7 @@ async def test_show_user_form_robot_unlock_with_password(hass: HomeAssistant) ->
assert result3["errors"] == {"password": "cannot_connect"} assert result3["errors"] == {"password": "cannot_connect"}
assert result3["step_id"] == "password" assert result3["step_id"] == "password"
assert result3["type"] == data_entry_flow.FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.romy.config_flow.romy.create_romy", "homeassistant.components.romy.config_flow.romy.create_romy",
@ -129,7 +130,7 @@ async def test_show_user_form_robot_unlock_with_password(hass: HomeAssistant) ->
) )
assert "errors" not in result4 assert "errors" not in result4
assert result4["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result4["type"] is FlowResultType.CREATE_ENTRY
async def test_show_user_form_robot_reachable_again(hass: HomeAssistant) -> None: async def test_show_user_form_robot_reachable_again(hass: HomeAssistant) -> None:
@ -148,7 +149,7 @@ async def test_show_user_form_robot_reachable_again(hass: HomeAssistant) -> None
assert result1["errors"].get("host") == "cannot_connect" assert result1["errors"].get("host") == "cannot_connect"
assert result1["step_id"] == "user" assert result1["step_id"] == "user"
assert result1["type"] == data_entry_flow.FlowResultType.FORM assert result1["type"] is FlowResultType.FORM
# Robot is locked # Robot is locked
with patch( with patch(
@ -160,7 +161,7 @@ async def test_show_user_form_robot_reachable_again(hass: HomeAssistant) -> None
) )
assert "errors" not in result2 assert "errors" not in result2
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
@ -188,7 +189,7 @@ async def test_zero_conf_locked_interface_robot(hass: HomeAssistant) -> None:
) )
assert result1["step_id"] == "password" assert result1["step_id"] == "password"
assert result1["type"] == data_entry_flow.FlowResultType.FORM assert result1["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.romy.config_flow.romy.create_romy", "homeassistant.components.romy.config_flow.romy.create_romy",
@ -199,7 +200,7 @@ async def test_zero_conf_locked_interface_robot(hass: HomeAssistant) -> None:
) )
assert "errors" not in result2 assert "errors" not in result2
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
async def test_zero_conf_uninitialized_robot(hass: HomeAssistant) -> None: async def test_zero_conf_uninitialized_robot(hass: HomeAssistant) -> None:
@ -216,7 +217,7 @@ async def test_zero_conf_uninitialized_robot(hass: HomeAssistant) -> None:
) )
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
async def test_zero_conf_unlocked_interface_robot(hass: HomeAssistant) -> None: async def test_zero_conf_unlocked_interface_robot(hass: HomeAssistant) -> None:
@ -233,7 +234,7 @@ async def test_zero_conf_unlocked_interface_robot(hass: HomeAssistant) -> None:
) )
assert result["step_id"] == "zeroconf_confirm" assert result["step_id"] == "zeroconf_confirm"
assert result["type"] == data_entry_flow.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"],
@ -246,4 +247,4 @@ async def test_zero_conf_unlocked_interface_robot(hass: HomeAssistant) -> None:
assert result["result"] assert result["result"]
assert result["result"].unique_id == "aicu-aicgsbksisfapcjqmqjq" assert result["result"].unique_id == "aicu-aicgsbksisfapcjqmqjq"
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY

View file

@ -2,9 +2,10 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.roon.const import DOMAIN from homeassistant.components.roon.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
@ -194,7 +195,7 @@ async def test_duplicate_config(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"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -5,7 +5,6 @@ from unittest.mock import MagicMock
import pytest import pytest
from requests.exceptions import ConnectTimeout, HTTPError from requests.exceptions import ConnectTimeout, HTTPError
from homeassistant import data_entry_flow
from homeassistant.components.rova.const import ( from homeassistant.components.rova.const import (
CONF_HOUSE_NUMBER, CONF_HOUSE_NUMBER,
CONF_HOUSE_NUMBER_SUFFIX, CONF_HOUSE_NUMBER_SUFFIX,
@ -14,6 +13,7 @@ from homeassistant.components.rova.const import (
) )
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.config_entries import SOURCE_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
@ -27,7 +27,7 @@ async def test_user(hass: HomeAssistant, mock_rova: MagicMock) -> 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.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"
# test with all information provided # test with all information provided
@ -40,7 +40,7 @@ async def test_user(hass: HomeAssistant, mock_rova: MagicMock) -> None:
CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX, CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX,
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
data = result.get("data") data = result.get("data")
assert data assert data
@ -69,7 +69,7 @@ async def test_error_if_not_rova_area(
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": "invalid_rova_area"} assert result.get("errors") == {"base": "invalid_rova_area"}
# now reset the return value and test if we can recover # now reset the return value and test if we can recover
@ -84,7 +84,7 @@ async def test_error_if_not_rova_area(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}" assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}"
assert result["data"] == { assert result["data"] == {
CONF_ZIP_CODE: ZIP_CODE, CONF_ZIP_CODE: ZIP_CODE,
@ -114,7 +114,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX, CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX,
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -145,7 +145,7 @@ async def test_abort_if_api_throws_exception(
CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX, CONF_HOUSE_NUMBER_SUFFIX: HOUSE_NUMBER_SUFFIX,
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": error} assert result.get("errors") == {"base": error}
# now reset the side effect to see if we can recover # now reset the side effect to see if we can recover
@ -160,7 +160,7 @@ async def test_abort_if_api_throws_exception(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}" assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}"
assert result["data"] == { assert result["data"] == {
CONF_ZIP_CODE: ZIP_CODE, CONF_ZIP_CODE: ZIP_CODE,
@ -181,7 +181,7 @@ async def test_import(hass: HomeAssistant, mock_rova: MagicMock) -> None:
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}" assert result["title"] == f"{ZIP_CODE} {HOUSE_NUMBER} {HOUSE_NUMBER_SUFFIX}"
assert result["data"] == { assert result["data"] == {
CONF_ZIP_CODE: ZIP_CODE, CONF_ZIP_CODE: ZIP_CODE,
@ -215,7 +215,7 @@ async def test_import_already_configured(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -237,7 +237,7 @@ async def test_import_if_not_rova_area(
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "invalid_rova_area" assert result.get("reason") == "invalid_rova_area"
@ -266,5 +266,5 @@ async def test_import_connection_errors(
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == error assert result.get("reason") == error

View file

@ -18,13 +18,13 @@ async def test_setup(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert not result["errors"] assert not result["errors"]
with patch(MODULE, return_value=MagicMock()): with patch(MODULE, return_value=MagicMock()):
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.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_not_supported(hass: HomeAssistant) -> None: async def test_not_supported(hass: HomeAssistant) -> None:
@ -36,7 +36,7 @@ async def test_not_supported(hass: HomeAssistant) -> None:
with patch(MODULE, return_value=None): with patch(MODULE, return_value=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"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found" assert result["reason"] == "no_devices_found"
@ -47,7 +47,7 @@ async def test_onboarding(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": "onboarding"}, context={"source": "onboarding"},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_onboarding_not_supported(hass: HomeAssistant) -> None: async def test_onboarding_not_supported(hass: HomeAssistant) -> None:
@ -57,5 +57,5 @@ async def test_onboarding_not_supported(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": "onboarding"}, context={"source": "onboarding"},
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found" assert result["reason"] == "no_devices_found"

View file

@ -11,7 +11,7 @@ from aioruckus.const import (
) )
from aioruckus.exceptions import AuthenticationError from aioruckus.exceptions import AuthenticationError
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.ruckus_unleashed.const import ( from homeassistant.components.ruckus_unleashed.const import (
API_SYS_SYSINFO, API_SYS_SYSINFO,
API_SYS_SYSINFO_SERIAL, API_SYS_SYSINFO_SERIAL,
@ -19,6 +19,7 @@ from homeassistant.components.ruckus_unleashed.const import (
) )
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.util import utcnow from homeassistant.util import utcnow
from . import ( from . import (
@ -37,7 +38,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 (
@ -54,7 +55,7 @@ async def test_form(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 result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == DEFAULT_TITLE assert result2["title"] == DEFAULT_TITLE
assert result2["data"] == CONFIG assert result2["data"] == CONFIG
@ -73,7 +74,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
CONFIG, CONFIG,
) )
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"}
@ -96,7 +97,7 @@ async def test_form_user_reauth(hass: HomeAssistant) -> None:
assert len(flows) == 1 assert len(flows) == 1
assert "flow_id" in flows[0] assert "flow_id" in flows[0]
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"] == {}
@ -111,7 +112,7 @@ async def test_form_user_reauth(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"
@ -134,7 +135,7 @@ async def test_form_user_reauth_different_unique_id(hass: HomeAssistant) -> None
assert len(flows) == 1 assert len(flows) == 1
assert "flow_id" in flows[0] assert "flow_id" in flows[0]
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"] == {}
@ -151,7 +152,7 @@ async def test_form_user_reauth_different_unique_id(hass: HomeAssistant) -> None
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_host"} assert result2["errors"] == {"base": "invalid_host"}
@ -174,7 +175,7 @@ async def test_form_user_reauth_invalid_auth(hass: HomeAssistant) -> None:
assert len(flows) == 1 assert len(flows) == 1
assert "flow_id" in flows[0] assert "flow_id" in flows[0]
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"] == {}
@ -191,7 +192,7 @@ async def test_form_user_reauth_invalid_auth(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
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"}
@ -214,7 +215,7 @@ async def test_form_user_reauth_cannot_connect(hass: HomeAssistant) -> None:
assert len(flows) == 1 assert len(flows) == 1
assert "flow_id" in flows[0] assert "flow_id" in flows[0]
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"] == {}
@ -231,7 +232,7 @@ async def test_form_user_reauth_cannot_connect(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
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"}
@ -254,7 +255,7 @@ async def test_form_user_reauth_general_exception(hass: HomeAssistant) -> None:
assert len(flows) == 1 assert len(flows) == 1
assert "flow_id" in flows[0] assert "flow_id" in flows[0]
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"] == {}
@ -269,7 +270,7 @@ async def test_form_user_reauth_general_exception(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.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"}
@ -288,7 +289,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
CONFIG, CONFIG,
) )
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"}
@ -304,7 +305,7 @@ async def test_form_general_exception(hass: HomeAssistant) -> None:
CONFIG, CONFIG,
) )
assert result2["type"] == data_entry_flow.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"}
@ -325,7 +326,7 @@ async def test_form_unexpected_response(hass: HomeAssistant) -> None:
CONFIG, CONFIG,
) )
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"}
@ -348,7 +349,7 @@ async def test_form_duplicate_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"] == data_entry_flow.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(
@ -356,5 +357,5 @@ async def test_form_duplicate_error(hass: HomeAssistant) -> None:
CONFIG, CONFIG,
) )
assert result2["type"] == data_entry_flow.FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -50,7 +50,7 @@ async def test_ok_setup(hass: HomeAssistant, init_data, init_context, entry) ->
data=init_data, data=init_data,
context=init_context, context=init_context,
) )
assert init_result["type"] == FlowResultType.FORM assert init_result["type"] is FlowResultType.FORM
assert init_result["step_id"] == config_entries.SOURCE_USER assert init_result["step_id"] == config_entries.SOURCE_USER
assert init_result["errors"] is None assert init_result["errors"] is None
@ -61,7 +61,7 @@ async def test_ok_setup(hass: HomeAssistant, init_data, init_context, entry) ->
entry, entry,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_result["type"] == FlowResultType.CREATE_ENTRY assert config_result["type"] is FlowResultType.CREATE_ENTRY
assert config_result["title"] == EXPECTED_TITLE assert config_result["title"] == EXPECTED_TITLE
assert config_result["data"] == entry assert config_result["data"] == entry
assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER
@ -80,7 +80,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
assert config_result["type"] == FlowResultType.FORM assert config_result["type"] is FlowResultType.FORM
assert config_result["errors"] == {"base": "invalid_auth"} assert config_result["errors"] == {"base": "invalid_auth"}
# Check that we still can finalize setup # Check that we still can finalize setup
@ -90,7 +90,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_result["type"] == FlowResultType.CREATE_ENTRY assert config_result["type"] is FlowResultType.CREATE_ENTRY
assert config_result["title"] == EXPECTED_TITLE assert config_result["title"] == EXPECTED_TITLE
assert config_result["data"] == BASE_DATA assert config_result["data"] == BASE_DATA
assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER
@ -109,7 +109,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
assert config_result["type"] == FlowResultType.FORM assert config_result["type"] is FlowResultType.FORM
assert config_result["errors"] == {"base": "cannot_connect"} assert config_result["errors"] == {"base": "cannot_connect"}
# Check that we still can finalize setup # Check that we still can finalize setup
@ -119,7 +119,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_result["type"] == FlowResultType.CREATE_ENTRY assert config_result["type"] is FlowResultType.CREATE_ENTRY
assert config_result["title"] == EXPECTED_TITLE assert config_result["title"] == EXPECTED_TITLE
assert config_result["data"] == BASE_DATA assert config_result["data"] == BASE_DATA
assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER
@ -138,7 +138,7 @@ async def test_form_unexpected(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
assert config_result["type"] == FlowResultType.FORM assert config_result["type"] is FlowResultType.FORM
assert config_result["errors"] == {"base": "unknown"} assert config_result["errors"] == {"base": "unknown"}
# Check that we still can finalize setup # Check that we still can finalize setup
@ -148,7 +148,7 @@ async def test_form_unexpected(hass: HomeAssistant) -> None:
BASE_DATA, BASE_DATA,
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_result["type"] == FlowResultType.CREATE_ENTRY assert config_result["type"] is FlowResultType.CREATE_ENTRY
assert config_result["title"] == EXPECTED_TITLE assert config_result["title"] == EXPECTED_TITLE
assert config_result["data"] == BASE_DATA assert config_result["data"] == BASE_DATA
assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER assert config_result["context"]["unique_id"] == GATEWAY_MAC_LOWER

View file

@ -26,7 +26,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=RUUVITAG_SERVICE_INFO, data=RUUVITAG_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(
"homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True "homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True
@ -34,7 +34,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address
@ -46,7 +46,7 @@ async def test_async_step_bluetooth_not_ruuvitag(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_RUUVITAG_SERVICE_INFO, data=NOT_RUUVITAG_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -56,7 +56,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"
@ -70,7 +70,7 @@ 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( with patch(
"homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True "homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True
@ -79,7 +79,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={"address": RUUVITAG_SERVICE_INFO.address}, user_input={"address": RUUVITAG_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address
@ -94,7 +94,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(
@ -110,7 +110,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"], result["flow_id"],
user_input={"address": RUUVITAG_SERVICE_INFO.address}, user_input={"address": RUUVITAG_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -132,7 +132,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"
@ -149,7 +149,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=RUUVITAG_SERVICE_INFO, data=RUUVITAG_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -160,7 +160,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=RUUVITAG_SERVICE_INFO, data=RUUVITAG_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(
@ -168,7 +168,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=RUUVITAG_SERVICE_INFO, data=RUUVITAG_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"
@ -181,7 +181,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=RUUVITAG_SERVICE_INFO, data=RUUVITAG_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(
@ -192,7 +192,7 @@ 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( with patch(
"homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True "homeassistant.components.ruuvitag_ble.async_setup_entry", return_value=True
@ -201,7 +201,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
result["flow_id"], result["flow_id"],
user_input={"address": RUUVITAG_SERVICE_INFO.address}, user_input={"address": RUUVITAG_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address assert result2["result"].unique_id == RUUVITAG_SERVICE_INFO.address

View file

@ -41,7 +41,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 (
@ -67,7 +67,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_DATA[CONF_EMAIL] assert result2["title"] == TEST_DATA[CONF_EMAIL]
assert result2["data"] == TEST_DATA assert result2["data"] == TEST_DATA
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -99,7 +99,7 @@ async def test_login_error(hass: HomeAssistant, exception, error) -> 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": error} assert result2["errors"] == {"base": error}
with ( with (
@ -125,7 +125,7 @@ async def test_login_error(hass: HomeAssistant, exception, error) -> 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_DATA[CONF_EMAIL] assert result3["title"] == TEST_DATA[CONF_EMAIL]
assert result3["data"] == TEST_DATA assert result3["data"] == TEST_DATA
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -156,7 +156,7 @@ async def test_form_already_exists(hass: HomeAssistant, config_entry) -> 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_configured" assert result2["reason"] == "already_configured"

View file

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, patch
from pysabnzbd import SabnzbdApiException from pysabnzbd import SabnzbdApiException
import pytest import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.sabnzbd import DOMAIN from homeassistant.components.sabnzbd import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.const import ( from homeassistant.const import (
@ -41,7 +41,7 @@ async def test_create_entry(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["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -54,7 +54,7 @@ async def test_create_entry(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
) )
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"] == "edc3eee7330e" assert result2["title"] == "edc3eee7330e"
assert result2["data"] == { assert result2["data"] == {
CONF_API_KEY: "edc3eee7330e4fdda04489e3fbc283d0", CONF_API_KEY: "edc3eee7330e4fdda04489e3fbc283d0",
@ -91,7 +91,7 @@ async def test_import_flow(hass: HomeAssistant) -> None:
data=VALID_CONFIG_OLD, data=VALID_CONFIG_OLD,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "edc3eee7330e" assert result["title"] == "edc3eee7330e"
assert result["data"][CONF_NAME] == "Sabnzbd" assert result["data"][CONF_NAME] == "Sabnzbd"
assert result["data"][CONF_API_KEY] == "edc3eee7330e4fdda04489e3fbc283d0" assert result["data"][CONF_API_KEY] == "edc3eee7330e4fdda04489e3fbc283d0"

View file

@ -358,7 +358,7 @@ async def test_user_legacy_missing_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_USER}, data=MOCK_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pairing" assert result["step_id"] == "pairing"
assert result["errors"] == {"base": "auth_missing"} assert result["errors"] == {"base": "auth_missing"}
@ -370,7 +370,7 @@ async def test_user_legacy_missing_auth(hass: HomeAssistant) -> None:
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.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == RESULT_CANNOT_CONNECT assert result2["reason"] == RESULT_CANNOT_CONNECT
@ -451,7 +451,7 @@ async def test_user_websocket_auth_retry(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}, data=MOCK_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pairing" assert result["step_id"] == "pairing"
assert result["errors"] == {"base": "auth_missing"} assert result["errors"] == {"base": "auth_missing"}
with ( with (
@ -466,7 +466,7 @@ async def test_user_websocket_auth_retry(hass: HomeAssistant) -> None:
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"] == "Living Room (82GXARRS)" assert result["title"] == "Living Room (82GXARRS)"
assert result["data"][CONF_HOST] == "fake_host" assert result["data"][CONF_HOST] == "fake_host"
assert result["data"][CONF_NAME] == "Living Room" assert result["data"][CONF_NAME] == "Living Room"
@ -561,7 +561,7 @@ async def test_ssdp_legacy_not_remote_control_receiver_udn(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=data DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=data
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == RESULT_NOT_SUPPORTED assert result["reason"] == RESULT_NOT_SUPPORTED
@ -607,7 +607,7 @@ async def test_ssdp_legacy_missing_auth(hass: HomeAssistant) -> None:
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pairing" assert result["step_id"] == "pairing"
assert result["errors"] == {"base": "auth_missing"} assert result["errors"] == {"base": "auth_missing"}
@ -616,7 +616,7 @@ async def test_ssdp_legacy_missing_auth(hass: HomeAssistant) -> None:
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"] == "fake_model" assert result["title"] == "fake_model"
assert result["data"][CONF_HOST] == "fake_host" assert result["data"][CONF_HOST] == "fake_host"
assert result["data"][CONF_NAME] == "fake_model" assert result["data"][CONF_NAME] == "fake_model"
@ -636,7 +636,7 @@ async def test_ssdp_legacy_not_supported(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_SSDP}, data=MOCK_SSDP_DATA DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == RESULT_NOT_SUPPORTED assert result["reason"] == RESULT_NOT_SUPPORTED
@ -768,7 +768,7 @@ async def test_ssdp_encrypted_websocket_not_supported(
context={"source": config_entries.SOURCE_SSDP}, context={"source": config_entries.SOURCE_SSDP},
data=MOCK_SSDP_DATA_RENDERING_CONTROL_ST, data=MOCK_SSDP_DATA_RENDERING_CONTROL_ST,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == RESULT_NOT_SUPPORTED assert result["reason"] == RESULT_NOT_SUPPORTED
@ -1176,7 +1176,7 @@ async def test_autodetect_auth_missing(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}, data=MOCK_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pairing" assert result["step_id"] == "pairing"
assert result["errors"] == {"base": "auth_missing"} assert result["errors"] == {"base": "auth_missing"}
@ -1191,7 +1191,7 @@ async def test_autodetect_auth_missing(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"] == RESULT_CANNOT_CONNECT assert result2["reason"] == RESULT_CANNOT_CONNECT
@ -2042,7 +2042,7 @@ async def test_ssdp_update_mac(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}, data=MOCK_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
entry = result["result"] entry = result["result"]
assert entry.data[CONF_MANUFACTURER] == DEFAULT_MANUFACTURER assert entry.data[CONF_MANUFACTURER] == DEFAULT_MANUFACTURER
assert entry.data[CONF_MODEL] == "fake_model" assert entry.data[CONF_MODEL] == "fake_model"
@ -2059,7 +2059,7 @@ async def test_ssdp_update_mac(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_SSDP}, data=MOCK_SSDP_DATA DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == RESULT_ALREADY_CONFIGURED assert result["reason"] == RESULT_ALREADY_CONFIGURED
# ensure mac wasn't updated with "none" # ensure mac wasn't updated with "none"
@ -2076,7 +2076,7 @@ async def test_ssdp_update_mac(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_SSDP}, data=MOCK_SSDP_DATA DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == RESULT_ALREADY_CONFIGURED assert result["reason"] == RESULT_ALREADY_CONFIGURED
# ensure mac was updated with new wifiMac value # ensure mac was updated with new wifiMac value

View file

@ -22,7 +22,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 result["errors"] == {} assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -35,7 +35,7 @@ async def test_form(
await hass.async_block_till_done() await hass.async_block_till_done()
mock_pyschlage_auth.authenticate.assert_called_once_with() mock_pyschlage_auth.authenticate.assert_called_once_with()
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",
@ -60,7 +60,7 @@ async def test_form_invalid_auth(
"password": "test-password", "password": "test-password",
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -79,7 +79,7 @@ async def test_form_unknown(hass: HomeAssistant, mock_pyschlage_auth: Mock) -> N
}, },
) )
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -105,7 +105,7 @@ async def test_reauth(
await hass.async_block_till_done() await hass.async_block_till_done()
mock_pyschlage_auth.authenticate.assert_called_once_with() mock_pyschlage_auth.authenticate.assert_called_once_with()
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful" assert result2["reason"] == "reauth_successful"
assert mock_added_config_entry.data == { assert mock_added_config_entry.data == {
"username": "asdf@asdf.com", "username": "asdf@asdf.com",
@ -138,7 +138,7 @@ async def test_reauth_invalid_auth(
await hass.async_block_till_done() await hass.async_block_till_done()
mock_pyschlage_auth.authenticate.assert_called_once_with() mock_pyschlage_auth.authenticate.assert_called_once_with()
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -165,7 +165,7 @@ async def test_reauth_wrong_account(
await hass.async_block_till_done() await hass.async_block_till_done()
mock_pyschlage_auth.authenticate.assert_called_once_with() mock_pyschlage_auth.authenticate.assert_called_once_with()
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "wrong_account" assert result2["reason"] == "wrong_account"
assert mock_added_config_entry.data == { assert mock_added_config_entry.data == {
"username": "asdf@asdf.com", "username": "asdf@asdf.com",

View file

@ -49,7 +49,7 @@ async def test_form(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.rest.RestData", "homeassistant.components.rest.RestData",
@ -75,7 +75,7 @@ async def test_form(
) )
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["version"] == 1 assert result3["version"] == 1
assert result3["options"] == { assert result3["options"] == {
CONF_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
@ -106,7 +106,7 @@ async def test_form_with_post(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.rest.RestData", "homeassistant.components.rest.RestData",
@ -133,7 +133,7 @@ async def test_form_with_post(
) )
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["version"] == 1 assert result3["version"] == 1
assert result3["options"] == { assert result3["options"] == {
CONF_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
@ -165,7 +165,7 @@ async def test_flow_fails(
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"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with patch( with patch(
@ -224,7 +224,7 @@ async def test_flow_fails(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result4["type"] == FlowResultType.CREATE_ENTRY assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["title"] == "https://www.home-assistant.io" assert result4["title"] == "https://www.home-assistant.io"
assert result4["options"] == { assert result4["options"] == {
CONF_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
@ -253,7 +253,7 @@ async def test_options_resource_flow(
result = await hass.config_entries.options.async_init(loaded_entry.entry_id) result = await hass.config_entries.options.async_init(loaded_entry.entry_id)
assert result["type"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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(
@ -261,7 +261,7 @@ async def test_options_resource_flow(
{"next_step_id": "resource"}, {"next_step_id": "resource"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "resource" assert result["step_id"] == "resource"
mocker = MockRestData("test_scrape_sensor2") mocker = MockRestData("test_scrape_sensor2")
@ -280,7 +280,7 @@ async def test_options_resource_flow(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",
@ -319,7 +319,7 @@ async def test_options_add_remove_sensor_flow(
result = await hass.config_entries.options.async_init(loaded_entry.entry_id) result = await hass.config_entries.options.async_init(loaded_entry.entry_id)
assert result["type"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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(
@ -327,7 +327,7 @@ async def test_options_add_remove_sensor_flow(
{"next_step_id": "add_sensor"}, {"next_step_id": "add_sensor"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "add_sensor" assert result["step_id"] == "add_sensor"
mocker = MockRestData("test_scrape_sensor2") mocker = MockRestData("test_scrape_sensor2")
@ -348,7 +348,7 @@ async def test_options_add_remove_sensor_flow(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",
@ -387,7 +387,7 @@ async def test_options_add_remove_sensor_flow(
result = await hass.config_entries.options.async_init(loaded_entry.entry_id) result = await hass.config_entries.options.async_init(loaded_entry.entry_id)
assert result["type"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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(
@ -395,7 +395,7 @@ async def test_options_add_remove_sensor_flow(
{"next_step_id": "remove_sensor"}, {"next_step_id": "remove_sensor"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "remove_sensor" assert result["step_id"] == "remove_sensor"
mocker = MockRestData("test_scrape_sensor2") mocker = MockRestData("test_scrape_sensor2")
@ -408,7 +408,7 @@ async def test_options_add_remove_sensor_flow(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",
@ -445,7 +445,7 @@ async def test_options_edit_sensor_flow(
result = await hass.config_entries.options.async_init(loaded_entry.entry_id) result = await hass.config_entries.options.async_init(loaded_entry.entry_id)
assert result["type"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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(
@ -453,7 +453,7 @@ async def test_options_edit_sensor_flow(
{"next_step_id": "select_edit_sensor"}, {"next_step_id": "select_edit_sensor"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_edit_sensor" assert result["step_id"] == "select_edit_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -461,7 +461,7 @@ async def test_options_edit_sensor_flow(
{"index": "0"}, {"index": "0"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "edit_sensor" assert result["step_id"] == "edit_sensor"
mocker = MockRestData("test_scrape_sensor2") mocker = MockRestData("test_scrape_sensor2")
@ -475,7 +475,7 @@ async def test_options_edit_sensor_flow(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",
@ -529,21 +529,21 @@ async def test_sensor_options_add_device_class(
entry.add_to_hass(hass) entry.add_to_hass(hass)
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"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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"], result["flow_id"],
{"next_step_id": "select_edit_sensor"}, {"next_step_id": "select_edit_sensor"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_edit_sensor" assert result["step_id"] == "select_edit_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], result["flow_id"],
{"index": "0"}, {"index": "0"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "edit_sensor" assert result["step_id"] == "edit_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -559,7 +559,7 @@ async def test_sensor_options_add_device_class(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",
@ -611,21 +611,21 @@ async def test_sensor_options_remove_device_class(
entry.add_to_hass(hass) entry.add_to_hass(hass)
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"] == FlowResultType.MENU assert result["type"] is FlowResultType.MENU
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"], result["flow_id"],
{"next_step_id": "select_edit_sensor"}, {"next_step_id": "select_edit_sensor"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_edit_sensor" assert result["step_id"] == "select_edit_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], result["flow_id"],
{"index": "0"}, {"index": "0"},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "edit_sensor" assert result["step_id"] == "edit_sensor"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -638,7 +638,7 @@ async def test_sensor_options_remove_device_class(
) )
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_RESOURCE: "https://www.home-assistant.io", CONF_RESOURCE: "https://www.home-assistant.io",
CONF_METHOD: "GET", CONF_METHOD: "GET",

View file

@ -20,7 +20,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(
@ -28,7 +28,7 @@ async def test_full_user_flow(
user_input={CONF_TYPE: TYPE_ASTRONOMICAL}, user_input={CONF_TYPE: TYPE_ASTRONOMICAL},
) )
assert result2.get("type") == FlowResultType.CREATE_ENTRY assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "Season" assert result2.get("title") == "Season"
assert result2.get("data") == {CONF_TYPE: TYPE_ASTRONOMICAL} assert result2.get("data") == {CONF_TYPE: TYPE_ASTRONOMICAL}
@ -44,5 +44,5 @@ async def test_single_instance_allowed(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_TYPE: TYPE_ASTRONOMICAL} DOMAIN, context={"source": SOURCE_USER}, data={CONF_TYPE: TYPE_ASTRONOMICAL}
) )
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"

View file

@ -26,7 +26,7 @@ async def test_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -51,7 +51,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["version"] == 2 assert result2["version"] == 2
assert result2["data"] == { assert result2["data"] == {
"api_key": "1234567890", "api_key": "1234567890",
@ -78,7 +78,7 @@ async def test_flow_fails(
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"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with patch( with patch(
@ -115,7 +115,7 @@ async def test_flow_fails(
}, },
) )
assert result3["type"] == FlowResultType.CREATE_ENTRY assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "Sensibo" assert result3["title"] == "Sensibo"
assert result3["data"] == { assert result3["data"] == {
"api_key": "1234567891", "api_key": "1234567891",
@ -129,7 +129,7 @@ async def test_flow_get_no_devices(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"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with ( with (
@ -159,7 +159,7 @@ async def test_flow_get_no_username(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"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with ( with (
@ -202,7 +202,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
data=entry.data, data=entry.data,
) )
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -225,7 +225,7 @@ async def test_reauth_flow(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 entry.data == {"api_key": "1234567891"} assert entry.data == {"api_key": "1234567891"}
@ -275,7 +275,7 @@ async def test_reauth_flow_error(
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["step_id"] == "reauth_confirm" assert result2["step_id"] == "reauth_confirm"
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": p_error} assert result2["errors"] == {"base": p_error}
with ( with (
@ -298,7 +298,7 @@ async def test_reauth_flow_error(
) )
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 entry.data == {"api_key": "1234567891"} assert entry.data == {"api_key": "1234567891"}
@ -348,7 +348,7 @@ async def test_flow_reauth_no_username_or_device(
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 (
@ -370,5 +370,5 @@ async def test_flow_reauth_no_username_or_device(
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["step_id"] == "reauth_confirm" assert result2["step_id"] == "reauth_confirm"
assert result2["type"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": p_error} assert result2["errors"] == {"base": p_error}

View file

@ -30,7 +30,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SENSIRION_SERVICE_INFO, data=SENSIRION_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(
"homeassistant.components.sensirion_ble.async_setup_entry", return_value=True "homeassistant.components.sensirion_ble.async_setup_entry", return_value=True
@ -38,7 +38,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address
@ -50,7 +50,7 @@ async def test_async_step_bluetooth_not_sensirion(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_SENSIRION_SERVICE_INFO, data=NOT_SENSIRION_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -60,7 +60,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"
@ -74,7 +74,7 @@ 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( with patch(
"homeassistant.components.sensirion_ble.async_setup_entry", return_value=True "homeassistant.components.sensirion_ble.async_setup_entry", return_value=True
@ -83,7 +83,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={"address": SENSIRION_SERVICE_INFO.address}, user_input={"address": SENSIRION_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address
@ -98,7 +98,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(
@ -114,7 +114,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"], result["flow_id"],
user_input={"address": SENSIRION_SERVICE_INFO.address}, user_input={"address": SENSIRION_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -136,7 +136,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"
@ -153,7 +153,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=SENSIRION_SERVICE_INFO, data=SENSIRION_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -164,7 +164,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=SENSIRION_SERVICE_INFO, data=SENSIRION_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(
@ -172,7 +172,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=SENSIRION_SERVICE_INFO, data=SENSIRION_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"
@ -185,7 +185,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SENSIRION_SERVICE_INFO, data=SENSIRION_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(
@ -196,7 +196,7 @@ 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( with patch(
"homeassistant.components.sensirion_ble.async_setup_entry", return_value=True "homeassistant.components.sensirion_ble.async_setup_entry", return_value=True
@ -205,7 +205,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
result["flow_id"], result["flow_id"],
user_input={"address": SENSIRION_SERVICE_INFO.address}, user_input={"address": SENSIRION_SERVICE_INFO.address},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == CONFIGURED_NAME assert result2["title"] == CONFIGURED_NAME
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address assert result2["result"].unique_id == SENSIRION_SERVICE_INFO.address

View file

@ -19,7 +19,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SENSORPRO_SERVICE_INFO, data=SENSORPRO_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(
"homeassistant.components.sensorpro.async_setup_entry", return_value=True "homeassistant.components.sensorpro.async_setup_entry", return_value=True
@ -27,7 +27,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == "T201 EEFF" assert result2["title"] == "T201 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"
@ -40,7 +40,7 @@ async def test_async_step_bluetooth_not_sensorpro(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_SENSORPRO_SERVICE_INFO, data=NOT_SENSORPRO_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -50,7 +50,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"
@ -64,7 +64,7 @@ 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( with patch(
"homeassistant.components.sensorpro.async_setup_entry", return_value=True "homeassistant.components.sensorpro.async_setup_entry", return_value=True
@ -73,7 +73,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
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"] == "T201 EEFF" assert result2["title"] == "T201 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"
@ -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(
@ -105,7 +105,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"
@ -127,7 +127,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"
@ -144,7 +144,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=SENSORPRO_SERVICE_INFO, data=SENSORPRO_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -155,7 +155,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=SENSORPRO_SERVICE_INFO, data=SENSORPRO_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(
@ -163,7 +163,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=SENSORPRO_SERVICE_INFO, data=SENSORPRO_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"
@ -176,7 +176,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SENSORPRO_SERVICE_INFO, data=SENSORPRO_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(
@ -187,7 +187,7 @@ 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( with patch(
"homeassistant.components.sensorpro.async_setup_entry", return_value=True "homeassistant.components.sensorpro.async_setup_entry", return_value=True
@ -196,7 +196,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
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"] == "T201 EEFF" assert result2["title"] == "T201 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"

View file

@ -19,7 +19,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=HTPWX_SERVICE_INFO, data=HTPWX_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(
"homeassistant.components.sensorpush.async_setup_entry", return_value=True "homeassistant.components.sensorpush.async_setup_entry", return_value=True
@ -27,7 +27,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
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"] == "HTP.xw F4D" assert result2["title"] == "HTP.xw F4D"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == "4125DDBA-2774-4851-9889-6AADDD4CAC3D" assert result2["result"].unique_id == "4125DDBA-2774-4851-9889-6AADDD4CAC3D"
@ -40,7 +40,7 @@ async def test_async_step_bluetooth_not_sensorpush(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_SENSOR_PUSH_SERVICE_INFO, data=NOT_SENSOR_PUSH_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -50,7 +50,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"
@ -64,7 +64,7 @@ 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( with patch(
"homeassistant.components.sensorpush.async_setup_entry", return_value=True "homeassistant.components.sensorpush.async_setup_entry", return_value=True
@ -73,7 +73,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"}, user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "HT.w 0CA1" assert result2["title"] == "HT.w 0CA1"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == "61DE521B-F0BF-9F44-64D4-75BBE1738105" assert result2["result"].unique_id == "61DE521B-F0BF-9F44-64D4-75BBE1738105"
@ -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(
@ -105,7 +105,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"], result["flow_id"],
user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"}, user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -127,7 +127,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"
@ -144,7 +144,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=HTW_SERVICE_INFO, data=HTW_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -155,7 +155,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=HTW_SERVICE_INFO, data=HTW_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(
@ -163,7 +163,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=HTW_SERVICE_INFO, data=HTW_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"
@ -176,7 +176,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=HTW_SERVICE_INFO, data=HTW_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(
@ -187,7 +187,7 @@ 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( with patch(
"homeassistant.components.sensorpush.async_setup_entry", return_value=True "homeassistant.components.sensorpush.async_setup_entry", return_value=True
@ -196,7 +196,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
result["flow_id"], result["flow_id"],
user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"}, user_input={"address": "61DE521B-F0BF-9F44-64D4-75BBE1738105"},
) )
assert result2["type"] == FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "HT.w 0CA1" assert result2["title"] == "HT.w 0CA1"
assert result2["data"] == {} assert result2["data"] == {}
assert result2["result"].unique_id == "61DE521B-F0BF-9F44-64D4-75BBE1738105" assert result2["result"].unique_id == "61DE521B-F0BF-9F44-64D4-75BBE1738105"

View file

@ -29,7 +29,7 @@ async def test_full_user_flow_implementation(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.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
with ( with (
@ -61,7 +61,7 @@ async def test_integration_already_exists(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.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"
@ -80,7 +80,7 @@ async def test_user_flow_bad_dsn(hass: HomeAssistant) -> None:
{"dsn": "foo"}, {"dsn": "foo"},
) )
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": "bad_dsn"} assert result2.get("errors") == {"base": "bad_dsn"}
@ -99,7 +99,7 @@ async def test_user_flow_unknown_exception(hass: HomeAssistant) -> None:
{"dsn": "foo"}, {"dsn": "foo"},
) )
assert result2.get("type") == FlowResultType.FORM assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": "unknown"} assert result2.get("errors") == {"base": "unknown"}
@ -117,7 +117,7 @@ async def test_options_flow(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.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "init" assert result.get("step_id") == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -134,7 +134,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
}, },
) )
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("data") == { assert result.get("data") == {
CONF_ENVIRONMENT: "Test", CONF_ENVIRONMENT: "Test",
CONF_EVENT_CUSTOM_COMPONENTS: True, CONF_EVENT_CUSTOM_COMPONENTS: True,

View file

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock
from py17track.errors import SeventeenTrackError from py17track.errors import SeventeenTrackError
import pytest import pytest
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.seventeentrack import DOMAIN from homeassistant.components.seventeentrack import DOMAIN
from homeassistant.components.seventeentrack.const import ( from homeassistant.components.seventeentrack.const import (
CONF_SHOW_ARCHIVED, CONF_SHOW_ARCHIVED,
@ -38,7 +38,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": 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(
@ -47,7 +47,7 @@ async def test_create_entry(
) )
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"] == "someemail@gmail.com" assert result2["title"] == "someemail@gmail.com"
assert result2["data"] == { assert result2["data"] == {
CONF_PASSWORD: "edc3eee7330e4fdda04489e3fbc283d0", CONF_PASSWORD: "edc3eee7330e4fdda04489e3fbc283d0",
@ -97,7 +97,7 @@ async def test_flow_fails(
) )
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"] == "someemail@gmail.com" assert result["title"] == "someemail@gmail.com"
assert result["data"] == { assert result["data"] == {
CONF_PASSWORD: "edc3eee7330e4fdda04489e3fbc283d0", CONF_PASSWORD: "edc3eee7330e4fdda04489e3fbc283d0",
@ -113,7 +113,7 @@ async def test_import_flow(hass: HomeAssistant, mock_seventeentrack: AsyncMock)
data=VALID_CONFIG_OLD, data=VALID_CONFIG_OLD,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "someemail@gmail.com" assert result["title"] == "someemail@gmail.com"
assert result["data"][CONF_USERNAME] == "someemail@gmail.com" assert result["data"][CONF_USERNAME] == "someemail@gmail.com"
assert result["data"][CONF_PASSWORD] == "edc3eee7330e4fdda04489e3fbc283d0" assert result["data"][CONF_PASSWORD] == "edc3eee7330e4fdda04489e3fbc283d0"
@ -150,7 +150,7 @@ async def test_import_flow_cannot_connect_error(
data=VALID_CONFIG_OLD, data=VALID_CONFIG_OLD,
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == error assert result["reason"] == error
@ -170,7 +170,7 @@ async def test_option_flow(hass: HomeAssistant, mock_seventeentrack: AsyncMock)
await hass.async_block_till_done() await hass.async_block_till_done()
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(
@ -178,7 +178,7 @@ async def test_option_flow(hass: HomeAssistant, mock_seventeentrack: AsyncMock)
user_input={CONF_SHOW_ARCHIVED: True, CONF_SHOW_DELIVERED: False}, user_input={CONF_SHOW_ARCHIVED: True, CONF_SHOW_DELIVERED: False},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_SHOW_ARCHIVED] assert result["data"][CONF_SHOW_ARCHIVED]
assert not result["data"][CONF_SHOW_DELIVERED] assert not result["data"][CONF_SHOW_DELIVERED]
@ -204,5 +204,5 @@ async def test_import_flow_already_configured(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result_aborted["type"] == data_entry_flow.FlowResultType.ABORT assert result_aborted["type"] is FlowResultType.ABORT
assert result_aborted["reason"] == "already_configured" assert result_aborted["reason"] == "already_configured"

View file

@ -7,11 +7,12 @@ import pytest
from sfrbox_api.exceptions import SFRBoxAuthenticationError, SFRBoxError from sfrbox_api.exceptions import SFRBoxAuthenticationError, SFRBoxError
from sfrbox_api.models import SystemInfo from sfrbox_api.models import SystemInfo
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.sfr_box.const import DOMAIN from homeassistant.components.sfr_box.const import DOMAIN
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_HOST, 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 load_fixture from tests.common import load_fixture
@ -25,7 +26,7 @@ async def test_config_flow_skip_auth(
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 patch( with patch(
@ -39,7 +40,7 @@ async def test_config_flow_skip_auth(
}, },
) )
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"}
with patch( with patch(
@ -55,7 +56,7 @@ async def test_config_flow_skip_auth(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.MENU assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "choose_auth" assert result["step_id"] == "choose_auth"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -63,7 +64,7 @@ async def test_config_flow_skip_auth(
{"next_step_id": "skip_auth"}, {"next_step_id": "skip_auth"},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "SFR Box" assert result["title"] == "SFR Box"
assert result["data"] == {CONF_HOST: "192.168.0.1"} assert result["data"] == {CONF_HOST: "192.168.0.1"}
@ -77,7 +78,7 @@ async def test_config_flow_with_auth(
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 patch( with patch(
@ -93,7 +94,7 @@ async def test_config_flow_with_auth(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.MENU assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "choose_auth" assert result["step_id"] == "choose_auth"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -113,7 +114,7 @@ async def test_config_flow_with_auth(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
with patch("homeassistant.components.sfr_box.config_flow.SFRBox.authenticate"): with patch("homeassistant.components.sfr_box.config_flow.SFRBox.authenticate"):
@ -125,7 +126,7 @@ async def test_config_flow_with_auth(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "SFR Box" assert result["title"] == "SFR Box"
assert result["data"] == { assert result["data"] == {
CONF_HOST: "192.168.0.1", CONF_HOST: "192.168.0.1",
@ -146,7 +147,7 @@ async def test_config_flow_duplicate_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN))) system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN)))
@ -163,7 +164,7 @@ async def test_config_flow_duplicate_host(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -180,7 +181,7 @@ async def test_config_flow_duplicate_mac(
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"] == {}
system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN))) system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN)))
@ -195,7 +196,7 @@ async def test_config_flow_duplicate_mac(
}, },
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -216,7 +217,7 @@ async def test_reauth(hass: HomeAssistant, config_entry_with_auth: ConfigEntry)
data=config_entry_with_auth.data, data=config_entry_with_auth.data,
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {} assert result.get("errors") == {}
# Failed credentials # Failed credentials
@ -232,7 +233,7 @@ async def test_reauth(hass: HomeAssistant, config_entry_with_auth: ConfigEntry)
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": "invalid_auth"} assert result.get("errors") == {"base": "invalid_auth"}
# Valid credentials # Valid credentials
@ -245,5 +246,5 @@ async def test_reauth(hass: HomeAssistant, config_entry_with_auth: ConfigEntry)
}, },
) )
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_successful" assert result.get("reason") == "reauth_successful"

View file

@ -15,7 +15,7 @@ from aioshelly.exceptions import (
) )
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.shelly import config_flow from homeassistant.components.shelly import config_flow
from homeassistant.components.shelly.const import ( from homeassistant.components.shelly.const import (
@ -26,6 +26,7 @@ from homeassistant.components.shelly.const import (
from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN
from homeassistant.config_entries import SOURCE_REAUTH from homeassistant.config_entries import SOURCE_REAUTH
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
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -74,7 +75,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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -102,7 +103,7 @@ async def test_form(
) )
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"] == "Test name" assert result2["title"] == "Test name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -123,7 +124,7 @@ async def test_form_gen1_custom_port(
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 (
@ -141,7 +142,7 @@ async def test_form_gen1_custom_port(
{"host": "1.1.1.1", "port": "1100"}, {"host": "1.1.1.1", "port": "1100"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"]["base"] == "custom_port_not_supported" assert result2["errors"]["base"] == "custom_port_not_supported"
@ -181,7 +182,7 @@ async def test_form_auth(
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 patch( with patch(
@ -193,7 +194,7 @@ async def test_form_auth(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -210,7 +211,7 @@ async def test_form_auth(
) )
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"] == "Test name" assert result3["title"] == "Test name"
assert result3["data"] == { assert result3["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -246,7 +247,7 @@ async def test_form_errors_get_info(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": base_error} assert result2["errors"] == {"base": base_error}
@ -267,7 +268,7 @@ async def test_form_missing_model_key(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "firmware_not_fully_provisioned"} assert result2["errors"] == {"base": "firmware_not_fully_provisioned"}
@ -278,7 +279,7 @@ async def test_form_missing_model_key_auth_enabled(
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 patch( with patch(
@ -290,14 +291,14 @@ async def test_form_missing_model_key_auth_enabled(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
monkeypatch.setattr(mock_rpc_device, "shelly", {"gen": 2}) monkeypatch.setattr(mock_rpc_device, "shelly", {"gen": 2})
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"], {"password": "1234"} result2["flow_id"], {"password": "1234"}
) )
assert result3["type"] == data_entry_flow.FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "firmware_not_fully_provisioned"} assert result3["errors"] == {"base": "firmware_not_fully_provisioned"}
@ -317,14 +318,14 @@ async def test_form_missing_model_key_zeroconf(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "firmware_not_fully_provisioned"} assert result["errors"] == {"base": "firmware_not_fully_provisioned"}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
{}, {},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "firmware_not_fully_provisioned"} assert result2["errors"] == {"base": "firmware_not_fully_provisioned"}
@ -357,7 +358,7 @@ async def test_form_errors_test_connection(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": base_error} assert result2["errors"] == {"base": base_error}
@ -382,7 +383,7 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
# Test config entry got updated with latest IP # Test config entry got updated with latest IP
@ -424,7 +425,7 @@ async def test_user_setup_ignored_device(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result2["type"] is FlowResultType.CREATE_ENTRY
# Test config entry got updated with latest IP # Test config entry got updated with latest IP
assert entry.data["host"] == "1.1.1.1" assert entry.data["host"] == "1.1.1.1"
@ -447,7 +448,7 @@ async def test_form_firmware_unsupported(hass: HomeAssistant) -> None:
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "unsupported_firmware" assert result2["reason"] == "unsupported_firmware"
@ -484,7 +485,7 @@ async def test_form_auth_errors_test_connection_gen1(
result2["flow_id"], result2["flow_id"],
{"username": "test username", "password": "test password"}, {"username": "test username", "password": "test password"},
) )
assert result3["type"] == data_entry_flow.FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": base_error} assert result3["errors"] == {"base": base_error}
@ -520,7 +521,7 @@ async def test_form_auth_errors_test_connection_gen2(
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"], {"password": "test password"} result2["flow_id"], {"password": "test password"}
) )
assert result3["type"] == data_entry_flow.FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": base_error} assert result3["errors"] == {"base": base_error}
@ -562,7 +563,7 @@ async def test_zeroconf(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
context = next( context = next(
flow["context"] flow["context"]
@ -586,7 +587,7 @@ async def test_zeroconf(
) )
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"] == "Test name" assert result2["title"] == "Test name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -621,7 +622,7 @@ async def test_zeroconf_sleeping_device(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
context = next( context = next(
flow["context"] flow["context"]
@ -644,7 +645,7 @@ async def test_zeroconf_sleeping_device(
) )
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"] == "Test name" assert result2["title"] == "Test name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -678,7 +679,7 @@ async def test_zeroconf_sleeping_device_error(hass: HomeAssistant) -> None:
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -699,7 +700,7 @@ async def test_zeroconf_already_configured(hass: HomeAssistant) -> None:
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
# Test config entry got updated with latest IP # Test config entry got updated with latest IP
@ -726,7 +727,7 @@ async def test_zeroconf_ignored(hass: HomeAssistant) -> None:
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
@ -749,7 +750,7 @@ async def test_zeroconf_with_wifi_ap_ip(hass: HomeAssistant) -> None:
), ),
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
# Test config entry was not updated with the wifi ap ip # Test config entry was not updated with the wifi ap ip
@ -768,7 +769,7 @@ async def test_zeroconf_firmware_unsupported(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unsupported_firmware" assert result["reason"] == "unsupported_firmware"
@ -783,7 +784,7 @@ async def test_zeroconf_cannot_connect(hass: HomeAssistant) -> None:
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -801,7 +802,7 @@ async def test_zeroconf_require_auth(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -819,7 +820,7 @@ async def test_zeroconf_require_auth(
) )
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"] == "Test name" assert result2["title"] == "Test name"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -865,7 +866,7 @@ async def test_reauth_successful(
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(
@ -873,7 +874,7 @@ async def test_reauth_successful(
user_input=user_input, user_input=user_input,
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"
@ -914,7 +915,7 @@ async def test_reauth_unsuccessful(
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(
@ -922,7 +923,7 @@ async def test_reauth_unsuccessful(
user_input=user_input, user_input=user_input,
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_unsuccessful" assert result["reason"] == "reauth_unsuccessful"
@ -947,7 +948,7 @@ async def test_reauth_get_info_error(hass: HomeAssistant, error: Exception) -> N
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(
@ -955,7 +956,7 @@ async def test_reauth_get_info_error(hass: HomeAssistant, error: Exception) -> N
user_input={"password": "test2 password"}, user_input={"password": "test2 password"},
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_unsuccessful" assert result["reason"] == "reauth_unsuccessful"
@ -1026,7 +1027,7 @@ async def test_options_flow_ble(hass: HomeAssistant, mock_rpc_device: Mock) -> N
"""Test setting ble options for gen2 devices.""" """Test setting ble options for gen2 devices."""
entry = await init_integration(hass, 2) entry = await init_integration(hass, 2)
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"
assert result["errors"] is None assert result["errors"] is None
@ -1038,11 +1039,11 @@ async def test_options_flow_ble(hass: HomeAssistant, mock_rpc_device: Mock) -> N
) )
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_BLE_SCANNER_MODE] == BLEScannerMode.DISABLED assert result["data"][CONF_BLE_SCANNER_MODE] == BLEScannerMode.DISABLED
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"
assert result["errors"] is None assert result["errors"] is None
@ -1054,11 +1055,11 @@ async def test_options_flow_ble(hass: HomeAssistant, mock_rpc_device: Mock) -> N
) )
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_BLE_SCANNER_MODE] == BLEScannerMode.ACTIVE assert result["data"][CONF_BLE_SCANNER_MODE] == BLEScannerMode.ACTIVE
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"
assert result["errors"] is None assert result["errors"] is None
@ -1070,7 +1071,7 @@ async def test_options_flow_ble(hass: HomeAssistant, mock_rpc_device: Mock) -> N
) )
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_BLE_SCANNER_MODE] == BLEScannerMode.PASSIVE assert result["data"][CONF_BLE_SCANNER_MODE] == BLEScannerMode.PASSIVE
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
@ -1099,7 +1100,7 @@ async def test_zeroconf_already_configured_triggers_refresh_mac_in_name(
data=DISCOVERY_INFO_WITH_MAC, data=DISCOVERY_INFO_WITH_MAC,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
monkeypatch.setattr(mock_rpc_device, "connected", False) monkeypatch.setattr(mock_rpc_device, "connected", False)
@ -1134,7 +1135,7 @@ async def test_zeroconf_already_configured_triggers_refresh(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
monkeypatch.setattr(mock_rpc_device, "connected", False) monkeypatch.setattr(mock_rpc_device, "connected", False)
@ -1176,7 +1177,7 @@ async def test_zeroconf_sleeping_device_not_triggers_refresh(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.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"
monkeypatch.setattr(mock_rpc_device, "connected", False) monkeypatch.setattr(mock_rpc_device, "connected", False)
@ -1197,7 +1198,7 @@ async def test_sleeping_device_gen2_with_new_firmware(
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 (

View file

@ -12,7 +12,7 @@ async def test_import(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data={} DOMAIN, context={"source": SOURCE_IMPORT}, data={}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_user(hass: HomeAssistant) -> None: async def test_user(hass: HomeAssistant) -> None:
@ -22,7 +22,7 @@ async def test_user(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"
@ -33,7 +33,7 @@ async def test_user_confirm(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data={} DOMAIN, context={"source": SOURCE_USER}, data={}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == {} assert result["result"].data == {}
@ -43,6 +43,6 @@ async def test_onboarding_flow(hass: HomeAssistant) -> None:
DOMAIN, context={"source": "onboarding"} DOMAIN, context={"source": "onboarding"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Shopping list" assert result["title"] == "Shopping list"
assert result["data"] == {} assert result["data"] == {}

View file

@ -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.sia.config_flow import ACCOUNT_SCHEMA, HUB_SCHEMA from homeassistant.components.sia.config_flow import ACCOUNT_SCHEMA, HUB_SCHEMA
from homeassistant.components.sia.const import ( from homeassistant.components.sia.const import (
CONF_ACCOUNT, CONF_ACCOUNT,
@ -18,6 +18,7 @@ from homeassistant.components.sia.const import (
) )
from homeassistant.const import CONF_PORT, CONF_PROTOCOL from homeassistant.const import CONF_PORT, CONF_PROTOCOL
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
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -164,9 +165,7 @@ async def test_form_start_account(
async def test_create(hass: HomeAssistant, entry_with_basic_config) -> None: async def test_create(hass: HomeAssistant, entry_with_basic_config) -> None:
"""Test we create a entry through the form.""" """Test we create a entry through the form."""
assert ( assert entry_with_basic_config["type"] is FlowResultType.CREATE_ENTRY
entry_with_basic_config["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
)
assert ( assert (
entry_with_basic_config["title"] entry_with_basic_config["title"]
== f"SIA Alarm on port {BASIC_CONFIG[CONF_PORT]}" == f"SIA Alarm on port {BASIC_CONFIG[CONF_PORT]}"
@ -179,10 +178,7 @@ async def test_create_additional_account(
hass: HomeAssistant, entry_with_additional_account_config hass: HomeAssistant, entry_with_additional_account_config
) -> None: ) -> None:
"""Test we create a config with two accounts.""" """Test we create a config with two accounts."""
assert ( assert entry_with_additional_account_config["type"] is FlowResultType.CREATE_ENTRY
entry_with_additional_account_config["type"]
== data_entry_flow.FlowResultType.CREATE_ENTRY
)
assert ( assert (
entry_with_additional_account_config["title"] entry_with_additional_account_config["title"]
== f"SIA Alarm on port {BASIC_CONFIG[CONF_PORT]}" == f"SIA Alarm on port {BASIC_CONFIG[CONF_PORT]}"
@ -322,7 +318,7 @@ async def test_options_basic(hass: HomeAssistant) -> None:
) )
await setup_sia(hass, config_entry) await setup_sia(hass, config_entry)
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"] == "options" assert result["step_id"] == "options"
assert result["last_step"] assert result["last_step"]
@ -330,7 +326,7 @@ async def test_options_basic(hass: HomeAssistant) -> None:
result["flow_id"], BASIC_OPTIONS result["flow_id"], BASIC_OPTIONS
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert updated["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert updated["type"] is FlowResultType.CREATE_ENTRY
assert updated["data"] == { assert updated["data"] == {
CONF_ACCOUNTS: {BASIC_CONFIG[CONF_ACCOUNT]: BASIC_OPTIONS} CONF_ACCOUNTS: {BASIC_CONFIG[CONF_ACCOUNT]: BASIC_OPTIONS}
} }
@ -348,13 +344,13 @@ async def test_options_additional(hass: HomeAssistant) -> None:
) )
await setup_sia(hass, config_entry) await setup_sia(hass, config_entry)
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"] == "options" assert result["step_id"] == "options"
assert not result["last_step"] assert not result["last_step"]
updated = await hass.config_entries.options.async_configure( updated = await hass.config_entries.options.async_configure(
result["flow_id"], BASIC_OPTIONS result["flow_id"], BASIC_OPTIONS
) )
assert updated["type"] == data_entry_flow.FlowResultType.FORM assert updated["type"] is FlowResultType.FORM
assert updated["step_id"] == "options" assert updated["step_id"] == "options"
assert updated["last_step"] assert updated["last_step"]

View file

@ -5,10 +5,11 @@ from unittest.mock import patch
import pytest import pytest
from simplepush import UnknownError from simplepush import UnknownError
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.simplepush.const import CONF_DEVICE_KEY, CONF_SALT, DOMAIN from homeassistant.components.simplepush.const import CONF_DEVICE_KEY, CONF_SALT, DOMAIN
from homeassistant.const import CONF_NAME, CONF_PASSWORD from homeassistant.const import CONF_NAME, CONF_PASSWORD
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
@ -44,7 +45,7 @@ async def test_flow_successful(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "simplepush" assert result["title"] == "simplepush"
assert result["data"] == MOCK_CONFIG assert result["data"] == MOCK_CONFIG
@ -60,7 +61,7 @@ async def test_flow_with_password(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=mock_config_pass, user_input=mock_config_pass,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "simplepush" assert result["title"] == "simplepush"
assert result["data"] == mock_config_pass assert result["data"] == mock_config_pass
@ -83,7 +84,7 @@ async def test_flow_user_device_key_already_configured(hass: HomeAssistant) -> N
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_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"
@ -108,7 +109,7 @@ async def test_flow_user_name_already_configured(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_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"
@ -126,5 +127,5 @@ async def test_error_on_connection_failure(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input=MOCK_CONFIG, user_input=MOCK_CONFIG,
) )
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"}

View file

@ -27,12 +27,12 @@ async def test_duplicate_error(
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
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"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE} result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -42,12 +42,12 @@ async def test_invalid_auth_code_length(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
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"], user_input={CONF_AUTH_CODE: "too_short_code"} result["flow_id"], user_input={CONF_AUTH_CODE: "too_short_code"}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth_code_length"} assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth_code_length"}
@ -61,13 +61,13 @@ async def test_invalid_credentials(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
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={CONF_AUTH_CODE: VALID_AUTH_CODE}, user_input={CONF_AUTH_CODE: VALID_AUTH_CODE},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth"} assert result["errors"] == {CONF_AUTH_CODE: "invalid_auth"}
@ -79,14 +79,14 @@ async def test_options_flow(config_entry, hass: HomeAssistant) -> None:
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"] == 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_CODE: "4321"} result["flow_id"], user_input={CONF_CODE: "4321"}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_CODE: "4321"} assert config_entry.options == {CONF_CODE: "4321"}
@ -108,7 +108,7 @@ async def test_step_reauth(config_entry, hass: HomeAssistant, 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"] == 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
@ -137,7 +137,7 @@ async def test_step_reauth_wrong_account(
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"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "wrong_account" assert result["reason"] == "wrong_account"
@ -178,7 +178,7 @@ async def test_step_user(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_AUTH_CODE: auth_code} result["flow_id"], user_input={CONF_AUTH_CODE: auth_code}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
if log_statement: if log_statement:
assert any(m for m in caplog.messages if log_statement in m) assert any(m for m in caplog.messages if log_statement in m)
@ -198,10 +198,10 @@ async def test_unknown_error(hass: HomeAssistant, setup_simplisafe) -> None:
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
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"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE} result["flow_id"], user_input={CONF_AUTH_CODE: VALID_AUTH_CODE}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}

View file

@ -33,7 +33,7 @@ async def test_flow_user(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"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -41,7 +41,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
user_input=CONF_DATA, user_input=CONF_DATA,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "user" assert result["title"] == "user"
assert result["data"] == CONF_DATA assert result["data"] == CONF_DATA
assert result["result"].unique_id == USER_ID assert result["result"].unique_id == USER_ID
@ -59,7 +59,7 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA
) )
assert result["type"] == 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_flow_user_cannot_connect(hass: HomeAssistant, skybell_mock) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, 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"}
@ -83,7 +83,7 @@ async def test_invalid_credentials(hass: HomeAssistant, skybell_mock) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, 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"}
@ -94,7 +94,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant, skybell_mock) -> Non
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, 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": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -114,14 +114,14 @@ async def test_step_reauth(hass: HomeAssistant) -> 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"
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_PASSWORD: PASSWORD}, user_input={CONF_PASSWORD: PASSWORD},
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"
@ -140,7 +140,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, skybell_mock) -> 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"
skybell_mock.async_initialize.side_effect = ( skybell_mock.async_initialize.side_effect = (
@ -151,7 +151,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, skybell_mock) -> None:
user_input={CONF_PASSWORD: PASSWORD}, user_input={CONF_PASSWORD: PASSWORD},
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
skybell_mock.async_initialize.side_effect = None skybell_mock.async_initialize.side_effect = None
@ -160,5 +160,5 @@ async def test_step_reauth_failed(hass: HomeAssistant, skybell_mock) -> None:
result["flow_id"], result["flow_id"],
user_input={CONF_PASSWORD: PASSWORD}, user_input={CONF_PASSWORD: PASSWORD},
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"

View file

@ -2,9 +2,10 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.slack.const import DOMAIN from homeassistant.components.slack.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import CONF_DATA, CONF_INPUT, TEAM_NAME, create_entry, mock_connection from . import CONF_DATA, CONF_INPUT, TEAM_NAME, create_entry, mock_connection
@ -24,7 +25,7 @@ async def test_flow_user(
result["flow_id"], result["flow_id"],
user_input=CONF_INPUT, user_input=CONF_INPUT,
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEAM_NAME assert result["title"] == TEAM_NAME
assert result["data"] == CONF_DATA assert result["data"] == CONF_DATA
@ -43,7 +44,7 @@ async def test_flow_user_already_configured(
result["flow_id"], result["flow_id"],
user_input=CONF_INPUT, user_input=CONF_INPUT,
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -57,7 +58,7 @@ async def test_flow_user_invalid_auth(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=CONF_DATA, data=CONF_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": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -72,7 +73,7 @@ async def test_flow_user_cannot_connect(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=CONF_DATA, data=CONF_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": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -88,6 +89,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_DATA, data=CONF_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": "unknown"} assert result["errors"] == {"base": "unknown"}

View file

@ -5,10 +5,11 @@ from unittest.mock import AsyncMock, patch
from asyncsleepiq import SleepIQLoginException, SleepIQTimeoutException from asyncsleepiq import SleepIQLoginException, SleepIQTimeoutException
import pytest import pytest
from homeassistant import config_entries, data_entry_flow, setup from homeassistant import config_entries, setup
from homeassistant.components.sleepiq.const import DOMAIN from homeassistant.components.sleepiq.const 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 .conftest import SLEEPIQ_CONFIG, setup_platform from .conftest import SLEEPIQ_CONFIG, setup_platform
@ -49,7 +50,7 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
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"
@ -70,7 +71,7 @@ async def test_login_failure(hass: HomeAssistant, side_effect, error) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=SLEEPIQ_CONFIG DOMAIN, context={"source": config_entries.SOURCE_USER}, data=SLEEPIQ_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"] == {"base": error} assert result["errors"] == {"base": error}
@ -89,7 +90,7 @@ async def test_success(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> 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["data"][CONF_USERNAME] == SLEEPIQ_CONFIG[CONF_USERNAME] assert result2["data"][CONF_USERNAME] == SLEEPIQ_CONFIG[CONF_USERNAME]
assert result2["data"][CONF_PASSWORD] == SLEEPIQ_CONFIG[CONF_PASSWORD] assert result2["data"][CONF_PASSWORD] == SLEEPIQ_CONFIG[CONF_PASSWORD]
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -124,5 +125,5 @@ async def test_reauth_password(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"

View file

@ -16,7 +16,7 @@ async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock)
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == DEFAULT_NAME assert result.get("title") == DEFAULT_NAME
assert result.get("data") == {} assert result.get("data") == {}
@ -35,5 +35,5 @@ async def test_already_configured(
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"

View file

@ -22,7 +22,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": 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 (
@ -36,7 +36,7 @@ async def test_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"] == MOCK_USER_INPUT["host"] assert result["title"] == MOCK_USER_INPUT["host"]
assert result["data"] == MOCK_USER_INPUT assert result["data"] == MOCK_USER_INPUT
@ -58,7 +58,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
MOCK_USER_INPUT, MOCK_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"}
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -78,7 +78,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
MOCK_USER_INPUT, MOCK_USER_INPUT,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -99,7 +99,7 @@ async def test_form_cannot_retrieve_device_info(hass: HomeAssistant) -> None:
MOCK_USER_INPUT, MOCK_USER_INPUT,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_retrieve_device_info"} assert result["errors"] == {"base": "cannot_retrieve_device_info"}
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -119,7 +119,7 @@ async def test_form_unexpected_exception(hass: HomeAssistant) -> None:
MOCK_USER_INPUT, MOCK_USER_INPUT,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -143,6 +143,6 @@ async def test_form_already_configured(hass: HomeAssistant, mock_config_entry) -
MOCK_USER_INPUT, MOCK_USER_INPUT,
) )
assert result["type"] == 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

View file

@ -4,7 +4,7 @@ from http import HTTPStatus
from ipaddress import ip_address from ipaddress import ip_address
from unittest.mock import patch from unittest.mock import patch
from homeassistant import data_entry_flow, setup from homeassistant import setup
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.components.smappee.const import ( from homeassistant.components.smappee.const import (
CONF_SERIALNUMBER, CONF_SERIALNUMBER,
@ -16,6 +16,7 @@ from homeassistant.components.smappee.const import (
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
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
@ -34,7 +35,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
async def test_show_user_host_form(hass: HomeAssistant) -> None: async def test_show_user_host_form(hass: HomeAssistant) -> None:
@ -44,14 +45,14 @@ async def test_show_user_host_form(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.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"], {"environment": ENV_LOCAL} result["flow_id"], {"environment": ENV_LOCAL}
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
async def test_show_zeroconf_connection_error_form(hass: HomeAssistant) -> None: async def test_show_zeroconf_connection_error_form(hass: HomeAssistant) -> None:
@ -72,14 +73,14 @@ async def test_show_zeroconf_connection_error_form(hass: HomeAssistant) -> None:
) )
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "1006000212"} assert result["description_placeholders"] == {CONF_SERIALNUMBER: "1006000212"}
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm" assert result["step_id"] == "zeroconf_confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
@ -104,14 +105,14 @@ async def test_show_zeroconf_connection_error_form_next_generation(
) )
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "5001000212"} assert result["description_placeholders"] == {CONF_SERIALNUMBER: "5001000212"}
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm" assert result["step_id"] == "zeroconf_confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
@ -127,19 +128,19 @@ async def test_connection_error(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.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"], {"environment": ENV_LOCAL} result["flow_id"], {"environment": ENV_LOCAL}
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.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"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
async def test_user_local_connection_error(hass: HomeAssistant) -> None: async def test_user_local_connection_error(hass: HomeAssistant) -> None:
@ -156,19 +157,19 @@ async def test_user_local_connection_error(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.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"], {"environment": ENV_LOCAL} result["flow_id"], {"environment": ENV_LOCAL}
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.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"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
async def test_zeroconf_wrong_mdns(hass: HomeAssistant) -> None: async def test_zeroconf_wrong_mdns(hass: HomeAssistant) -> None:
@ -188,7 +189,7 @@ async def test_zeroconf_wrong_mdns(hass: HomeAssistant) -> None:
) )
assert result["reason"] == "invalid_mdns" assert result["reason"] == "invalid_mdns"
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
async def test_full_user_wrong_mdns(hass: HomeAssistant) -> None: async def test_full_user_wrong_mdns(hass: HomeAssistant) -> None:
@ -212,18 +213,18 @@ async def test_full_user_wrong_mdns(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.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"], {"environment": ENV_LOCAL} result["flow_id"], {"environment": ENV_LOCAL}
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.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"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_mdns" assert result["reason"] == "invalid_mdns"
@ -257,18 +258,18 @@ async def test_user_device_exists_abort(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.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"], {"environment": ENV_LOCAL} result["flow_id"], {"environment": ENV_LOCAL}
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.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"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
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(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -312,7 +313,7 @@ async def test_zeroconf_device_exists_abort(hass: HomeAssistant) -> None:
properties={"_raw": {}}, properties={"_raw": {}},
), ),
) )
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(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -333,7 +334,7 @@ async def test_cloud_device_exists_abort(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_device" assert result["reason"] == "already_configured_device"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -362,7 +363,7 @@ async def test_zeroconf_abort_if_cloud_device_exists(hass: HomeAssistant) -> Non
properties={"_raw": {}}, properties={"_raw": {}},
), ),
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_device" assert result["reason"] == "already_configured_device"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -396,7 +397,7 @@ async def test_zeroconf_confirm_abort_if_cloud_device_exists(
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"] == "already_configured_device" assert result["reason"] == "already_configured_device"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -421,7 +422,7 @@ async def test_abort_cloud_flow_if_local_device_exists(hass: HomeAssistant) -> N
result["flow_id"], {"environment": ENV_CLOUD} result["flow_id"], {"environment": ENV_CLOUD}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_local_device" assert result["reason"] == "already_configured_local_device"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -511,7 +512,7 @@ async def test_full_zeroconf_flow(hass: HomeAssistant) -> None:
properties={"_raw": {}}, properties={"_raw": {}},
), ),
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm" assert result["step_id"] == "zeroconf_confirm"
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "1006000212"} assert result["description_placeholders"] == {CONF_SERIALNUMBER: "1006000212"}
@ -519,7 +520,7 @@ async def test_full_zeroconf_flow(hass: HomeAssistant) -> None:
result["flow_id"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "smappee1006000212" assert result["title"] == "smappee1006000212"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -549,7 +550,7 @@ async def test_full_user_local_flow(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
) )
assert result["step_id"] == "environment" assert result["step_id"] == "environment"
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] is None assert result["description_placeholders"] is None
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -557,12 +558,12 @@ async def test_full_user_local_flow(hass: HomeAssistant) -> None:
{"environment": ENV_LOCAL}, {"environment": ENV_LOCAL},
) )
assert result["step_id"] == ENV_LOCAL assert result["step_id"] == ENV_LOCAL
assert result["type"] == data_entry_flow.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"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "smappee1006000212" assert result["title"] == "smappee1006000212"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
@ -596,7 +597,7 @@ async def test_full_zeroconf_flow_next_generation(hass: HomeAssistant) -> None:
properties={"_raw": {}}, properties={"_raw": {}},
), ),
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm" assert result["step_id"] == "zeroconf_confirm"
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "5001000212"} assert result["description_placeholders"] == {CONF_SERIALNUMBER: "5001000212"}
@ -604,7 +605,7 @@ async def test_full_zeroconf_flow_next_generation(hass: HomeAssistant) -> None:
result["flow_id"], {"host": "1.2.3.4"} result["flow_id"], {"host": "1.2.3.4"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "smappee5001000212" assert result["title"] == "smappee5001000212"
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1

View file

@ -8,7 +8,7 @@ from aiohttp import ClientResponseError
from pysmartthings import APIResponseError from pysmartthings import APIResponseError
from pysmartthings.installedapp import format_install_url from pysmartthings.installedapp import format_install_url
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.smartthings import smartapp from homeassistant.components.smartthings import smartapp
from homeassistant.components.smartthings.const import ( from homeassistant.components.smartthings.const import (
CONF_APP_ID, CONF_APP_ID,
@ -19,6 +19,7 @@ from homeassistant.components.smartthings.const import (
from homeassistant.config import async_process_ha_core_config from homeassistant.config import async_process_ha_core_config
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET
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
@ -29,7 +30,7 @@ async def test_import_shows_user_step(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_IMPORT} DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
) )
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["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -56,7 +57,7 @@ async def test_entry_created(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -64,7 +65,7 @@ async def test_entry_created(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -73,14 +74,14 @@ async def test_entry_created(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_location" assert result["step_id"] == "select_location"
# Select location and advance to external auth # Select location and advance to external auth
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_LOCATION_ID: location.location_id} result["flow_id"], {CONF_LOCATION_ID: location.location_id}
) )
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["step_id"] == "authorize" assert result["step_id"] == "authorize"
assert result["url"] == format_install_url(app.app_id, location.location_id) assert result["url"] == format_install_url(app.app_id, location.location_id)
@ -89,7 +90,7 @@ async def test_entry_created(
# Finish # Finish
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
assert result["data"]["app_id"] == app.app_id assert result["data"]["app_id"] == app.app_id
assert result["data"]["installed_app_id"] == installed_app_id assert result["data"]["installed_app_id"] == installed_app_id
assert result["data"]["location_id"] == location.location_id assert result["data"]["location_id"] == location.location_id
@ -127,7 +128,7 @@ async def test_entry_created_from_update_event(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -135,7 +136,7 @@ async def test_entry_created_from_update_event(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -144,14 +145,14 @@ async def test_entry_created_from_update_event(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_location" assert result["step_id"] == "select_location"
# Select location and advance to external auth # Select location and advance to external auth
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_LOCATION_ID: location.location_id} result["flow_id"], {CONF_LOCATION_ID: location.location_id}
) )
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["step_id"] == "authorize" assert result["step_id"] == "authorize"
assert result["url"] == format_install_url(app.app_id, location.location_id) assert result["url"] == format_install_url(app.app_id, location.location_id)
@ -160,7 +161,7 @@ async def test_entry_created_from_update_event(
# Finish # Finish
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
assert result["data"]["app_id"] == app.app_id assert result["data"]["app_id"] == app.app_id
assert result["data"]["installed_app_id"] == installed_app_id assert result["data"]["installed_app_id"] == installed_app_id
assert result["data"]["location_id"] == location.location_id assert result["data"]["location_id"] == location.location_id
@ -199,7 +200,7 @@ async def test_entry_created_existing_app_new_oauth_client(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -207,7 +208,7 @@ async def test_entry_created_existing_app_new_oauth_client(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -216,14 +217,14 @@ async def test_entry_created_existing_app_new_oauth_client(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_location" assert result["step_id"] == "select_location"
# Select location and advance to external auth # Select location and advance to external auth
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_LOCATION_ID: location.location_id} result["flow_id"], {CONF_LOCATION_ID: location.location_id}
) )
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["step_id"] == "authorize" assert result["step_id"] == "authorize"
assert result["url"] == format_install_url(app.app_id, location.location_id) assert result["url"] == format_install_url(app.app_id, location.location_id)
@ -232,7 +233,7 @@ async def test_entry_created_existing_app_new_oauth_client(
# Finish # Finish
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
assert result["data"]["app_id"] == app.app_id assert result["data"]["app_id"] == app.app_id
assert result["data"]["installed_app_id"] == installed_app_id assert result["data"]["installed_app_id"] == installed_app_id
assert result["data"]["location_id"] == location.location_id assert result["data"]["location_id"] == location.location_id
@ -283,7 +284,7 @@ async def test_entry_created_existing_app_copies_oauth_client(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -291,7 +292,7 @@ async def test_entry_created_existing_app_copies_oauth_client(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -302,14 +303,14 @@ async def test_entry_created_existing_app_copies_oauth_client(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_location" assert result["step_id"] == "select_location"
# Select location and advance to external auth # Select location and advance to external auth
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_LOCATION_ID: location.location_id} result["flow_id"], {CONF_LOCATION_ID: location.location_id}
) )
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["step_id"] == "authorize" assert result["step_id"] == "authorize"
assert result["url"] == format_install_url(app.app_id, location.location_id) assert result["url"] == format_install_url(app.app_id, location.location_id)
@ -318,7 +319,7 @@ async def test_entry_created_existing_app_copies_oauth_client(
# Finish # Finish
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
assert result["data"]["app_id"] == app.app_id assert result["data"]["app_id"] == app.app_id
assert result["data"]["installed_app_id"] == installed_app_id assert result["data"]["installed_app_id"] == installed_app_id
assert result["data"]["location_id"] == location.location_id assert result["data"]["location_id"] == location.location_id
@ -377,7 +378,7 @@ async def test_entry_created_with_cloudhook(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -387,7 +388,7 @@ async def test_entry_created_with_cloudhook(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -396,14 +397,14 @@ async def test_entry_created_with_cloudhook(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select_location" assert result["step_id"] == "select_location"
# Select location and advance to external auth # Select location and advance to external auth
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_LOCATION_ID: location.location_id} result["flow_id"], {CONF_LOCATION_ID: location.location_id}
) )
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["step_id"] == "authorize" assert result["step_id"] == "authorize"
assert result["url"] == format_install_url(app.app_id, location.location_id) assert result["url"] == format_install_url(app.app_id, location.location_id)
@ -412,7 +413,7 @@ async def test_entry_created_with_cloudhook(
# Finish # Finish
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
assert result["data"]["app_id"] == app.app_id assert result["data"]["app_id"] == app.app_id
assert result["data"]["installed_app_id"] == installed_app_id assert result["data"]["installed_app_id"] == installed_app_id
assert result["data"]["location_id"] == location.location_id assert result["data"]["location_id"] == location.location_id
@ -440,7 +441,7 @@ async def test_invalid_webhook_aborts(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"] == "invalid_webhook_url" assert result["reason"] == "invalid_webhook_url"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -456,7 +457,7 @@ async def test_invalid_token_shows_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"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -464,7 +465,7 @@ async def test_invalid_token_shows_error(hass: HomeAssistant) -> None:
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -473,7 +474,7 @@ async def test_invalid_token_shows_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {CONF_ACCESS_TOKEN: "token_invalid_format"} assert result["errors"] == {CONF_ACCESS_TOKEN: "token_invalid_format"}
@ -495,7 +496,7 @@ async def test_unauthorized_token_shows_error(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -503,7 +504,7 @@ async def test_unauthorized_token_shows_error(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -512,7 +513,7 @@ async def test_unauthorized_token_shows_error(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {CONF_ACCESS_TOKEN: "token_unauthorized"} assert result["errors"] == {CONF_ACCESS_TOKEN: "token_unauthorized"}
@ -534,7 +535,7 @@ async def test_forbidden_token_shows_error(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -542,7 +543,7 @@ async def test_forbidden_token_shows_error(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -551,7 +552,7 @@ async def test_forbidden_token_shows_error(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {CONF_ACCESS_TOKEN: "token_forbidden"} assert result["errors"] == {CONF_ACCESS_TOKEN: "token_forbidden"}
@ -579,7 +580,7 @@ async def test_webhook_problem_shows_error(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -587,7 +588,7 @@ async def test_webhook_problem_shows_error(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -596,7 +597,7 @@ async def test_webhook_problem_shows_error(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {"base": "webhook_error"} assert result["errors"] == {"base": "webhook_error"}
@ -621,7 +622,7 @@ async def test_api_error_shows_error(hass: HomeAssistant, smartthings_mock) -> N
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -629,7 +630,7 @@ async def test_api_error_shows_error(hass: HomeAssistant, smartthings_mock) -> N
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -638,7 +639,7 @@ async def test_api_error_shows_error(hass: HomeAssistant, smartthings_mock) -> N
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {"base": "app_setup_error"} assert result["errors"] == {"base": "app_setup_error"}
@ -661,7 +662,7 @@ async def test_unknown_response_error_shows_error(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -669,7 +670,7 @@ async def test_unknown_response_error_shows_error(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -678,7 +679,7 @@ async def test_unknown_response_error_shows_error(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {"base": "app_setup_error"} assert result["errors"] == {"base": "app_setup_error"}
@ -695,7 +696,7 @@ async def test_unknown_error_shows_error(hass: HomeAssistant, smartthings_mock)
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -703,7 +704,7 @@ async def test_unknown_error_shows_error(hass: HomeAssistant, smartthings_mock)
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -712,7 +713,7 @@ async def test_unknown_error_shows_error(hass: HomeAssistant, smartthings_mock)
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pat" assert result["step_id"] == "pat"
assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token} assert result["data_schema"]({}) == {CONF_ACCESS_TOKEN: token}
assert result["errors"] == {"base": "app_setup_error"} assert result["errors"] == {"base": "app_setup_error"}
@ -737,7 +738,7 @@ async def test_no_available_locations_aborts(
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"
assert result["description_placeholders"][ assert result["description_placeholders"][
"webhook_url" "webhook_url"
@ -745,7 +746,7 @@ async def test_no_available_locations_aborts(
# Advance to PAT screen # Advance to PAT screen
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"] == "pat" assert result["step_id"] == "pat"
assert "token_url" in result["description_placeholders"] assert "token_url" in result["description_placeholders"]
assert "component_url" in result["description_placeholders"] assert "component_url" in result["description_placeholders"]
@ -754,5 +755,5 @@ async def test_no_available_locations_aborts(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: token} result["flow_id"], {CONF_ACCESS_TOKEN: token}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_available_locations" assert result["reason"] == "no_available_locations"

View file

@ -4,10 +4,11 @@ from unittest.mock import patch
from smarttub import LoginFailed from smarttub import LoginFailed
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries
from homeassistant.components.smarttub.const import DOMAIN from homeassistant.components.smarttub.const import DOMAIN
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
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_reauth_success(hass: HomeAssistant, smarttub_api, account) -> Non
data=mock_entry.data, data=mock_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(
result["flow_id"], {CONF_EMAIL: "test-email3", CONF_PASSWORD: "test-password3"} result["flow_id"], {CONF_EMAIL: "test-email3", CONF_PASSWORD: "test-password3"}
) )
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 mock_entry.data[CONF_EMAIL] == "test-email3" assert mock_entry.data[CONF_EMAIL] == "test-email3"
assert mock_entry.data[CONF_PASSWORD] == "test-password3" assert mock_entry.data[CONF_PASSWORD] == "test-password3"
@ -116,12 +117,12 @@ async def test_reauth_wrong_account(hass: HomeAssistant, smarttub_api, account)
data=mock_entry2.data, data=mock_entry2.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(
result["flow_id"], {CONF_EMAIL: "test-email1", CONF_PASSWORD: "test-password1"} result["flow_id"], {CONF_EMAIL: "test-email1", CONF_PASSWORD: "test-password1"}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -26,7 +26,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 (
@ -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["title"] == "Home" assert result2["title"] == "Home"
assert result2["data"] == { assert result2["data"] == {
"location": { "location": {
@ -86,7 +86,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result4["type"] == FlowResultType.CREATE_ENTRY assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["title"] == "Weather 1.0 1.0" assert result4["title"] == "Weather 1.0 1.0"
assert result4["data"] == { assert result4["data"] == {
"location": { "location": {
@ -118,7 +118,7 @@ async def test_form_invalid_coordinates(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": "wrong_location"} assert result2["errors"] == {"base": "wrong_location"}
# Continue flow with new coordinates # Continue flow with new coordinates
@ -143,7 +143,7 @@ async def test_form_invalid_coordinates(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"] == "Weather 2.0 2.0" assert result3["title"] == "Weather 2.0 2.0"
assert result3["data"] == { assert result3["data"] == {
"location": { "location": {
@ -187,7 +187,7 @@ async def test_form_unique_id_exist(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_configured" assert result2["reason"] == "already_configured"
@ -224,7 +224,7 @@ async def test_reconfigure_flow(
"entry_id": entry.entry_id, "entry_id": entry.entry_id,
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.smhi.config_flow.Smhi.async_get_forecast", "homeassistant.components.smhi.config_flow.Smhi.async_get_forecast",
@ -241,7 +241,7 @@ async def test_reconfigure_flow(
) )
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": "wrong_location"} assert result["errors"] == {"base": "wrong_location"}
with ( with (
@ -265,7 +265,7 @@ async def test_reconfigure_flow(
) )
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"] == "reconfigure_successful" assert result["reason"] == "reconfigure_successful"
entry = hass.config_entries.async_get_entry(entry.entry_id) entry = hass.config_entries.async_get_entry(entry.entry_id)
assert entry.title == "Home" assert entry.title == "Home"

View file

@ -26,7 +26,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 result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -38,7 +38,7 @@ async def test_form(
) )
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_host"} assert result["errors"] == {"base": "invalid_host"}
@ -50,7 +50,7 @@ async def test_form(
) )
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"}
@ -60,7 +60,7 @@ async def test_form(
) )
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"] == "Snapcast" assert result["title"] == "Snapcast"
assert result["data"] == {CONF_HOST: "snapserver.test", CONF_PORT: 1705} assert result["data"] == {CONF_HOST: "snapserver.test", CONF_PORT: 1705}
assert len(mock_create_server.mock_calls) == 1 assert len(mock_create_server.mock_calls) == 1
@ -80,7 +80,7 @@ async def test_abort(
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 not result["errors"] assert not result["errors"]
@ -91,5 +91,5 @@ async def test_abort(
) )
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"

View file

@ -30,7 +30,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SNOOZ_SERVICE_INFO_PAIRING, data=SNOOZ_SERVICE_INFO_PAIRING,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm" assert result["step_id"] == "bluetooth_confirm"
await _test_setup_entry(hass, result["flow_id"]) await _test_setup_entry(hass, result["flow_id"])
@ -44,7 +44,7 @@ async def test_async_step_bluetooth_waits_to_pair(hass: HomeAssistant) -> None:
data=SNOOZ_SERVICE_INFO_NOT_PAIRING, data=SNOOZ_SERVICE_INFO_NOT_PAIRING,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm" assert result["step_id"] == "bluetooth_confirm"
await _test_pairs(hass, result["flow_id"]) await _test_pairs(hass, result["flow_id"])
@ -59,7 +59,7 @@ async def test_async_step_bluetooth_retries_pairing(hass: HomeAssistant) -> None
data=SNOOZ_SERVICE_INFO_NOT_PAIRING, data=SNOOZ_SERVICE_INFO_NOT_PAIRING,
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm" assert result["step_id"] == "bluetooth_confirm"
retry_id = await _test_pairs_timeout(hass, result["flow_id"]) retry_id = await _test_pairs_timeout(hass, result["flow_id"])
@ -73,7 +73,7 @@ async def test_async_step_bluetooth_not_snooz(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_SNOOZ_SERVICE_INFO, data=NOT_SNOOZ_SERVICE_INFO,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -83,7 +83,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"
@ -97,7 +97,7 @@ 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"
assert result["data_schema"] assert result["data_schema"]
# ensure discovered devices are listed as options # ensure discovered devices are listed as options
@ -119,7 +119,7 @@ async def test_async_step_user_with_found_devices_waits_to_pair(
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"
await _test_pairs(hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}) await _test_pairs(hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME})
@ -137,7 +137,7 @@ async def test_async_step_user_with_found_devices_retries_pairing(
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"
user_input = {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME} user_input = {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}
@ -156,7 +156,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(
@ -171,7 +171,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"], result["flow_id"],
user_input={CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}, user_input={CONF_NAME: TEST_SNOOZ_DISPLAY_NAME},
) )
assert result2["type"] == FlowResultType.ABORT assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -194,7 +194,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"
@ -212,7 +212,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=SNOOZ_SERVICE_INFO_PAIRING, data=SNOOZ_SERVICE_INFO_PAIRING,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -223,7 +223,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=SNOOZ_SERVICE_INFO_PAIRING, data=SNOOZ_SERVICE_INFO_PAIRING,
) )
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(
@ -231,7 +231,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=SNOOZ_SERVICE_INFO_PAIRING, data=SNOOZ_SERVICE_INFO_PAIRING,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -244,7 +244,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH}, context={"source": config_entries.SOURCE_BLUETOOTH},
data=SNOOZ_SERVICE_INFO_PAIRING, data=SNOOZ_SERVICE_INFO_PAIRING,
) )
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(
@ -255,7 +255,7 @@ 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
await _test_setup_entry( await _test_setup_entry(
hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME} hass, result["flow_id"], {CONF_NAME: TEST_SNOOZ_DISPLAY_NAME}
@ -286,7 +286,7 @@ async def _test_pairs(
flow_id, flow_id,
user_input=user_input or {}, user_input=user_input or {},
) )
assert result["type"] == FlowResultType.SHOW_PROGRESS assert result["type"] is FlowResultType.SHOW_PROGRESS
assert result["step_id"] == "wait_for_pairing_mode" assert result["step_id"] == "wait_for_pairing_mode"
pairing_mode_entered.set() pairing_mode_entered.set()
@ -305,12 +305,12 @@ async def _test_pairs_timeout(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
flow_id, user_input=user_input or {} flow_id, user_input=user_input or {}
) )
assert result["type"] == FlowResultType.SHOW_PROGRESS assert result["type"] is FlowResultType.SHOW_PROGRESS
assert result["step_id"] == "wait_for_pairing_mode" assert result["step_id"] == "wait_for_pairing_mode"
await hass.async_block_till_done() await hass.async_block_till_done()
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"] == FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pairing_timeout" assert result2["step_id"] == "pairing_timeout"
return result2["flow_id"] return result2["flow_id"]
@ -325,7 +325,7 @@ async def _test_setup_entry(
user_input=user_input or {}, user_input=user_input or {},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_ADDRESS: TEST_ADDRESS, CONF_ADDRESS: TEST_ADDRESS,
CONF_TOKEN: TEST_PAIRING_TOKEN, CONF_TOKEN: TEST_PAIRING_TOKEN,

View file

@ -5,11 +5,11 @@ from unittest.mock import Mock, patch
import pytest import pytest
from requests.exceptions import ConnectTimeout, HTTPError from requests.exceptions import ConnectTimeout, HTTPError
from homeassistant import data_entry_flow
from homeassistant.components.solaredge.const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN from homeassistant.components.solaredge.const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN
from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_USER from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_NAME from homeassistant.const import CONF_API_KEY, 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
@ -32,7 +32,7 @@ async def test_user(hass: HomeAssistant, test_api: Mock) -> 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.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"
# test with all provided # test with all provided
@ -41,7 +41,7 @@ async def test_user(hass: HomeAssistant, test_api: Mock) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID}, data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
) )
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "solaredge_site_1_2_3" assert result.get("title") == "solaredge_site_1_2_3"
data = result.get("data") data = result.get("data")
@ -63,7 +63,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_api: str) -> Non
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"}, data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"},
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_SITE_ID: "already_configured"} assert result.get("errors") == {CONF_SITE_ID: "already_configured"}
@ -83,7 +83,7 @@ async def test_ignored_entry_does_not_cause_error(
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"}, data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"},
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "test" assert result["title"] == "test"
data = result["data"] data = result["data"]
@ -103,7 +103,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID}, data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_SITE_ID: "site_not_active"} assert result.get("errors") == {CONF_SITE_ID: "site_not_active"}
# test with api_failure # test with api_failure
@ -113,7 +113,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID}, data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_SITE_ID: "invalid_api_key"} assert result.get("errors") == {CONF_SITE_ID: "invalid_api_key"}
# test with ConnectionTimeout # test with ConnectionTimeout
@ -123,7 +123,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID}, data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"} assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"}
# test with HTTPError # test with HTTPError
@ -133,5 +133,5 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID}, data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
) )
assert result.get("type") == data_entry_flow.FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"} assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"}

View file

@ -4,11 +4,12 @@ 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.solarlog import config_flow from homeassistant.components.solarlog import config_flow
from homeassistant.components.solarlog.const import DEFAULT_HOST, DOMAIN from homeassistant.components.solarlog.const import DEFAULT_HOST, DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME from homeassistant.const import CONF_HOST, 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
@ -68,12 +69,12 @@ async def test_user(hass: HomeAssistant, test_connect) -> 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"] == "user" assert result["step_id"] == "user"
# tets with all provided # tets with all provided
result = await flow.async_step_user({CONF_NAME: NAME, CONF_HOST: HOST}) result = await flow.async_step_user({CONF_NAME: NAME, CONF_HOST: HOST})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog_test_1_2_3" assert result["title"] == "solarlog_test_1_2_3"
assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_HOST] == HOST
@ -84,19 +85,19 @@ async def test_import(hass: HomeAssistant, test_connect) -> None:
# import with only host # import with only host
result = await flow.async_step_import({CONF_HOST: HOST}) result = await flow.async_step_import({CONF_HOST: HOST})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog" assert result["title"] == "solarlog"
assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_HOST] == HOST
# import with only name # import with only name
result = await flow.async_step_import({CONF_NAME: NAME}) result = await flow.async_step_import({CONF_NAME: NAME})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog_test_1_2_3" assert result["title"] == "solarlog_test_1_2_3"
assert result["data"][CONF_HOST] == DEFAULT_HOST assert result["data"][CONF_HOST] == DEFAULT_HOST
# import with host and name # import with host and name
result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME}) result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog_test_1_2_3" assert result["title"] == "solarlog_test_1_2_3"
assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_HOST] == HOST
@ -112,19 +113,19 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None
result = await flow.async_step_import( result = await flow.async_step_import(
{CONF_HOST: HOST, CONF_NAME: "solarlog_test_7_8_9"} {CONF_HOST: HOST, CONF_NAME: "solarlog_test_7_8_9"}
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
# Should fail, same HOST and NAME # Should fail, same HOST and NAME
result = await flow.async_step_user({CONF_HOST: HOST, CONF_NAME: NAME}) result = await flow.async_step_user({CONF_HOST: HOST, CONF_NAME: NAME})
assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_HOST: "already_configured"} assert result["errors"] == {CONF_HOST: "already_configured"}
# SHOULD pass, diff HOST (without http://), different NAME # SHOULD pass, diff HOST (without http://), different NAME
result = await flow.async_step_import( result = await flow.async_step_import(
{CONF_HOST: "2.2.2.2", CONF_NAME: "solarlog_test_7_8_9"} {CONF_HOST: "2.2.2.2", CONF_NAME: "solarlog_test_7_8_9"}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog_test_7_8_9" assert result["title"] == "solarlog_test_7_8_9"
assert result["data"][CONF_HOST] == "http://2.2.2.2" assert result["data"][CONF_HOST] == "http://2.2.2.2"
@ -132,6 +133,6 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None
result = await flow.async_step_import( result = await flow.async_step_import(
{CONF_HOST: "http://2.2.2.2", CONF_NAME: NAME} {CONF_HOST: "http://2.2.2.2", CONF_NAME: NAME}
) )
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "solarlog_test_1_2_3" assert result["title"] == "solarlog_test_1_2_3"
assert result["data"][CONF_HOST] == "http://2.2.2.2" assert result["data"][CONF_HOST] == "http://2.2.2.2"

View file

@ -5,9 +5,9 @@ from unittest.mock import patch
from api.soma_api import SomaApi from api.soma_api import SomaApi
from requests import RequestException from requests import RequestException
from homeassistant import data_entry_flow
from homeassistant.components.soma import DOMAIN, config_flow from homeassistant.components.soma import DOMAIN, config_flow
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
@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant) -> None:
flow = config_flow.SomaFlowHandler() flow = config_flow.SomaFlowHandler()
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.FORM assert result["type"] is FlowResultType.FORM
async def test_import_abort(hass: HomeAssistant) -> None: async def test_import_abort(hass: HomeAssistant) -> None:
@ -29,7 +29,7 @@ async def test_import_abort(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
MockConfigEntry(domain=DOMAIN).add_to_hass(hass) MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
result = await flow.async_step_import() result = await flow.async_step_import()
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_setup" assert result["reason"] == "already_setup"
@ -39,7 +39,7 @@ async def test_import_create(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}): with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_error_status(hass: HomeAssistant) -> None: async def test_error_status(hass: HomeAssistant) -> None:
@ -48,7 +48,7 @@ async def test_error_status(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "error"}): with patch.object(SomaApi, "list_devices", return_value={"result": "error"}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "result_error" assert result["reason"] == "result_error"
@ -58,7 +58,7 @@ async def test_key_error(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={}): with patch.object(SomaApi, "list_devices", return_value={}):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "connection_error" assert result["reason"] == "connection_error"
@ -68,7 +68,7 @@ async def test_exception(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
with patch.object(SomaApi, "list_devices", side_effect=RequestException()): with patch.object(SomaApi, "list_devices", side_effect=RequestException()):
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT}) result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "connection_error" assert result["reason"] == "connection_error"
@ -79,4 +79,4 @@ async def test_full_flow(hass: HomeAssistant) -> None:
flow.hass = hass flow.hass = hass
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}): with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
result = await flow.async_step_user({"host": MOCK_HOST, "port": MOCK_PORT}) result = await flow.async_step_user({"host": MOCK_HOST, "port": MOCK_PORT})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY

View file

@ -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 import dhcp from homeassistant.components import dhcp
from homeassistant.components.somfy_mylink.const import ( from homeassistant.components.somfy_mylink.const import (
CONF_REVERSED_TARGET_IDS, CONF_REVERSED_TARGET_IDS,
@ -13,6 +13,7 @@ from homeassistant.components.somfy_mylink.const import (
) )
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, 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
@ -182,7 +183,7 @@ async def test_options_not_loaded(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)
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
@pytest.mark.parametrize("reversed", [True, False]) @pytest.mark.parametrize("reversed", [True, False])
@ -211,7 +212,7 @@ async def test_options_with_targets(hass: HomeAssistant, reversed) -> 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)
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"
result2 = await hass.config_entries.options.async_configure( result2 = await hass.config_entries.options.async_configure(
@ -219,19 +220,19 @@ async def test_options_with_targets(hass: HomeAssistant, reversed) -> None:
user_input={"target_id": "a"}, user_input={"target_id": "a"},
) )
assert result2["type"] == data_entry_flow.FlowResultType.FORM assert result2["type"] is FlowResultType.FORM
result3 = await hass.config_entries.options.async_configure( result3 = await hass.config_entries.options.async_configure(
result2["flow_id"], result2["flow_id"],
user_input={"reverse": reversed}, user_input={"reverse": reversed},
) )
assert result3["type"] == data_entry_flow.FlowResultType.FORM assert result3["type"] is FlowResultType.FORM
result4 = await hass.config_entries.options.async_configure( result4 = await hass.config_entries.options.async_configure(
result3["flow_id"], result3["flow_id"],
user_input={"target_id": None}, user_input={"target_id": None},
) )
assert result4["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result4["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == { assert config_entry.options == {
CONF_REVERSED_TARGET_IDS: {"a": reversed}, CONF_REVERSED_TARGET_IDS: {"a": reversed},

View file

@ -29,7 +29,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_cannot_connect( async def test_cannot_connect(
@ -45,7 +45,7 @@ async def test_cannot_connect(
data=user_input, data=user_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": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -65,7 +65,7 @@ async def test_invalid_auth(
data=user_input, data=user_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": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -83,7 +83,7 @@ async def test_unknown_error(
data=user_input, data=user_input,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -106,14 +106,14 @@ async def test_full_reauth_flow_implementation(
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"
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.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
user_input = MOCK_REAUTH_INPUT.copy() user_input = MOCK_REAUTH_INPUT.copy()
@ -122,7 +122,7 @@ async def test_full_reauth_flow_implementation(
) )
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[CONF_API_KEY] == "test-api-key-reauth" assert entry.data[CONF_API_KEY] == "test-api-key-reauth"
@ -139,7 +139,7 @@ async def test_full_user_flow_implementation(
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"
user_input = MOCK_USER_INPUT.copy() user_input = MOCK_USER_INPUT.copy()
@ -149,7 +149,7 @@ async def test_full_user_flow_implementation(
user_input=user_input, user_input=user_input,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "192.168.1.189" assert result["title"] == "192.168.1.189"
assert result["data"] assert result["data"]
@ -166,7 +166,7 @@ async def test_full_user_flow_advanced_options(
DOMAIN, context={CONF_SOURCE: SOURCE_USER, "show_advanced_options": True} DOMAIN, context={CONF_SOURCE: SOURCE_USER, "show_advanced_options": True}
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
user_input = { user_input = {
@ -179,7 +179,7 @@ async def test_full_user_flow_advanced_options(
user_input=user_input, user_input=user_input,
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "192.168.1.189" assert result["title"] == "192.168.1.189"
assert result["data"] assert result["data"]
@ -201,7 +201,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)
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(
@ -210,6 +210,6 @@ async def test_options_flow(
) )
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_UPCOMING_DAYS] == 2 assert result["data"][CONF_UPCOMING_DAYS] == 2
assert result["data"][CONF_WANTED_MAX_ITEMS] == 100 assert result["data"][CONF_WANTED_MAX_ITEMS] == 100

View file

@ -77,7 +77,7 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None:
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"] == FRIENDLY_NAME assert result["title"] == FRIENDLY_NAME
assert result["data"] == CONF_DATA assert result["data"] == CONF_DATA
@ -91,7 +91,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, 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"] is None assert result["errors"] is None
_flow_next(hass, result["flow_id"]) _flow_next(hass, result["flow_id"])
@ -100,7 +100,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
result["flow_id"], result["flow_id"],
user_input={CONF_ENDPOINT: ENDPOINT}, user_input={CONF_ENDPOINT: ENDPOINT},
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MODEL assert result["title"] == MODEL
assert result["data"] == { assert result["data"] == {
CONF_NAME: MODEL, CONF_NAME: MODEL,
@ -119,7 +119,7 @@ async def test_flow_import(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == FRIENDLY_NAME assert result["title"] == FRIENDLY_NAME
assert result["data"] == CONF_DATA assert result["data"] == CONF_DATA
@ -135,7 +135,7 @@ async def test_flow_import_without_name(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_ENDPOINT: ENDPOINT} DOMAIN, context={"source": SOURCE_IMPORT}, data={CONF_ENDPOINT: ENDPOINT}
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MODEL assert result["title"] == MODEL
assert result["data"] == {CONF_NAME: MODEL, CONF_ENDPOINT: ENDPOINT} assert result["data"] == {CONF_NAME: MODEL, CONF_ENDPOINT: ENDPOINT}
@ -163,7 +163,7 @@ async def test_ssdp_bravia(hass: HomeAssistant) -> None:
context={"source": SOURCE_SSDP}, context={"source": SOURCE_SSDP},
data=ssdp_data, data=ssdp_data,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_songpal_device" assert result["reason"] == "not_songpal_device"
@ -175,7 +175,7 @@ async def test_sddp_exist(hass: HomeAssistant) -> None:
context={"source": SOURCE_SSDP}, context={"source": SOURCE_SSDP},
data=SSDP_DATA, data=SSDP_DATA,
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -188,7 +188,7 @@ async def test_user_exist(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=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
mocked_device.get_supported_methods.assert_called_once() mocked_device.get_supported_methods.assert_called_once()
@ -204,7 +204,7 @@ async def test_import_exist(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
mocked_device.get_supported_methods.assert_called_once() mocked_device.get_supported_methods.assert_called_once()
@ -220,7 +220,7 @@ async def test_user_invalid(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=CONF_DATA DOMAIN, context={"source": SOURCE_USER}, 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"}
@ -237,7 +237,7 @@ async def test_import_invalid(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA DOMAIN, context={"source": SOURCE_IMPORT}, data=CONF_DATA
) )
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
mocked_device.get_supported_methods.assert_called_once() mocked_device.get_supported_methods.assert_called_once()

View file

@ -26,7 +26,7 @@ async def test_user_flow_create_entry(
context={CONF_SOURCE: SOURCE_USER}, context={CONF_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"
with patch( with patch(
@ -41,7 +41,7 @@ async def test_user_flow_create_entry(
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == DEVICE_1_NAME assert result.get("title") == DEVICE_1_NAME
assert result.get("data") == { assert result.get("data") == {
CONF_HOST: DEVICE_1_IP, CONF_HOST: DEVICE_1_IP,
@ -65,7 +65,7 @@ async def test_user_flow_cannot_connect(
}, },
) )
assert result["type"] == FlowResultType.FORM assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -92,7 +92,7 @@ async def test_zeroconf_flow_create_entry(
), ),
) )
assert result.get("type") == FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "zeroconf_confirm" assert result.get("step_id") == "zeroconf_confirm"
assert result.get("description_placeholders") == {"name": DEVICE_1_NAME} assert result.get("description_placeholders") == {"name": DEVICE_1_NAME}
@ -105,7 +105,7 @@ async def test_zeroconf_flow_create_entry(
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
assert result.get("type") == FlowResultType.CREATE_ENTRY assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == DEVICE_1_NAME assert result.get("title") == DEVICE_1_NAME
assert result.get("data") == { assert result.get("data") == {
CONF_HOST: DEVICE_1_IP, CONF_HOST: DEVICE_1_IP,

View file

@ -20,13 +20,13 @@ async def test_flow_works(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
speedtestdotnet.DOMAIN, context={"source": config_entries.SOURCE_USER} speedtestdotnet.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"
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
async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None: async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None:
@ -41,7 +41,7 @@ async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
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"] == 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(
@ -51,7 +51,7 @@ async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None:
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1", CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1",
CONF_SERVER_ID: "1", CONF_SERVER_ID: "1",
@ -60,7 +60,7 @@ async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None:
# test setting server name to "*Auto Detect" # test setting server name to "*Auto Detect"
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"] == 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(
@ -70,7 +70,7 @@ async def test_options(hass: HomeAssistant, mock_api: MagicMock) -> None:
}, },
) )
assert result["type"] == FlowResultType.CREATE_ENTRY assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_SERVER_NAME: "*Auto Detect", CONF_SERVER_NAME: "*Auto Detect",
CONF_SERVER_ID: None, CONF_SERVER_ID: None,
@ -86,5 +86,5 @@ async def test_integration_already_configured(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
speedtestdotnet.DOMAIN, context={"source": config_entries.SOURCE_USER} speedtestdotnet.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"

View file

@ -4,10 +4,11 @@ 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.spider.const import DOMAIN from homeassistant.components.spider.const 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
@ -34,7 +35,7 @@ async def test_user(hass: HomeAssistant, spider) -> None:
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"
with ( with (
@ -50,7 +51,7 @@ async def test_user(hass: HomeAssistant, spider) -> 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"] == DOMAIN assert result["title"] == DOMAIN
assert result["data"][CONF_USERNAME] == USERNAME assert result["data"][CONF_USERNAME] == USERNAME
assert result["data"][CONF_PASSWORD] == PASSWORD assert result["data"][CONF_PASSWORD] == PASSWORD
@ -80,7 +81,7 @@ async def test_import(hass: HomeAssistant, spider) -> 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"] == DOMAIN assert result["title"] == DOMAIN
assert result["data"][CONF_USERNAME] == USERNAME assert result["data"][CONF_USERNAME] == USERNAME
assert result["data"][CONF_PASSWORD] == PASSWORD assert result["data"][CONF_PASSWORD] == PASSWORD
@ -99,7 +100,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, spider) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=SPIDER_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=SPIDER_USER_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"
# Should fail, config exist (flow) # Should fail, config exist (flow)
@ -107,5 +108,5 @@ async def test_abort_if_already_setup(hass: HomeAssistant, spider) -> None:
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=SPIDER_USER_DATA DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=SPIDER_USER_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"

View file

@ -7,7 +7,6 @@ from unittest.mock import patch
import pytest import pytest
from spotipy import SpotifyException from spotipy import SpotifyException
from homeassistant import data_entry_flow
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.components.application_credentials import ( from homeassistant.components.application_credentials import (
ClientCredential, ClientCredential,
@ -16,6 +15,7 @@ from homeassistant.components.application_credentials import (
from homeassistant.components.spotify.const import DOMAIN from homeassistant.components.spotify.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 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
@ -53,14 +53,14 @@ async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
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"] == "missing_credentials" assert result["reason"] == "missing_credentials"
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=BLANK_ZEROCONF_INFO DOMAIN, context={"source": SOURCE_ZEROCONF}, data=BLANK_ZEROCONF_INFO
) )
assert result["type"] == data_entry_flow.FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "missing_credentials" assert result["reason"] == "missing_credentials"
@ -72,7 +72,7 @@ async def test_zeroconf_abort_if_existing_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=BLANK_ZEROCONF_INFO DOMAIN, context={"source": SOURCE_ZEROCONF}, data=BLANK_ZEROCONF_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"
@ -96,7 +96,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"] == (
"https://accounts.spotify.com/authorize" "https://accounts.spotify.com/authorize"
"?response_type=code&client_id=client" "?response_type=code&client_id=client"
@ -181,7 +181,7 @@ async def test_abort_if_spotify_error(
): ):
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"] == "connection_error" assert result["reason"] == "connection_error"
@ -306,7 +306,7 @@ async def test_reauth_account_mismatch(
spotify_mock.return_value.current_user.return_value = {"id": "fake_id"} spotify_mock.return_value.current_user.return_value = {"id": "fake_id"}
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_account_mismatch" assert result["reason"] == "reauth_account_mismatch"
@ -316,5 +316,5 @@ async def test_abort_if_no_reauth_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": "reauth_confirm"} DOMAIN, context={"source": "reauth_confirm"}
) )
assert result.get("type") == data_entry_flow.FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_account_mismatch" assert result.get("reason") == "reauth_account_mismatch"

Some files were not shown because too many files have changed in this diff Show more