Use is in FlowResultType enum comparison in tests (#114917)
* Use is in FlowResultType enum comparison in tests * Adjust auth * Adjust systemmonitor * Once more * Add comment
This commit is contained in:
parent
04e5086e01
commit
24f83c5890
25 changed files with 165 additions and 147 deletions
|
@ -26,6 +26,7 @@ from homeassistant.const import (
|
|||
CONF_NAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -163,7 +164,7 @@ class OAuthFixture:
|
|||
)
|
||||
|
||||
result = await self.hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == self.title
|
||||
assert "data" in result
|
||||
assert "token" in result["data"]
|
||||
|
@ -420,7 +421,7 @@ async def test_config_flow_no_credentials(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_credentials"
|
||||
|
||||
|
||||
|
@ -447,7 +448,7 @@ async def test_config_flow_other_domain(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_credentials"
|
||||
|
||||
|
||||
|
@ -470,7 +471,7 @@ async def test_config_flow(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result.get("type") is FlowResultType.EXTERNAL_STEP
|
||||
result = await oauth_fixture.complete_external_step(result)
|
||||
assert (
|
||||
result["data"].get("auth_implementation") == "fake_integration_some_client_id"
|
||||
|
@ -535,14 +536,14 @@ async def test_config_flow_multiple_entries(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "pick_implementation"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"implementation": "fake_integration_some_client_id2"},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result.get("type") is FlowResultType.EXTERNAL_STEP
|
||||
oauth_fixture.client_id = CLIENT_ID + "2"
|
||||
oauth_fixture.title = CLIENT_ID + "2"
|
||||
result = await oauth_fixture.complete_external_step(result)
|
||||
|
@ -572,7 +573,7 @@ async def test_config_flow_create_delete_credential(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_credentials"
|
||||
|
||||
|
||||
|
@ -589,7 +590,7 @@ async def test_config_flow_with_config_credential(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result.get("type") is FlowResultType.EXTERNAL_STEP
|
||||
oauth_fixture.title = DEFAULT_IMPORT_NAME
|
||||
result = await oauth_fixture.complete_external_step(result)
|
||||
# Uses the imported auth domain for compatibility
|
||||
|
@ -607,7 +608,7 @@ async def test_import_without_setup(hass: HomeAssistant, config_credential) -> N
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_configuration"
|
||||
|
||||
|
||||
|
@ -636,7 +637,7 @@ async def test_websocket_without_platform(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_configuration"
|
||||
|
||||
|
||||
|
@ -711,7 +712,7 @@ async def test_platform_with_auth_implementation(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result.get("type") is FlowResultType.EXTERNAL_STEP
|
||||
oauth_fixture.title = DEFAULT_IMPORT_NAME
|
||||
result = await oauth_fixture.complete_external_step(result)
|
||||
# Uses the imported auth domain for compatibility
|
||||
|
@ -769,7 +770,7 @@ async def test_name(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
TEST_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result.get("type") is FlowResultType.EXTERNAL_STEP
|
||||
oauth_fixture.title = NAME
|
||||
result = await oauth_fixture.complete_external_step(result)
|
||||
assert (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue