Use is in enum comparison in config flow tests P-T (#114675)
This commit is contained in:
parent
5d500cb74b
commit
ee66f6ec8c
164 changed files with 1919 additions and 1890 deletions
|
@ -7,11 +7,12 @@ import pytest
|
|||
from sfrbox_api.exceptions import SFRBoxAuthenticationError, SFRBoxError
|
||||
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.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
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(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
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"}
|
||||
|
||||
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"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
|
@ -63,7 +64,7 @@ async def test_config_flow_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["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(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
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"
|
||||
|
||||
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"}
|
||||
|
||||
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["data"] == {
|
||||
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(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
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"
|
||||
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(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
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"
|
||||
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,
|
||||
)
|
||||
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
# 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"}
|
||||
|
||||
# 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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue