Use FlowResultType enum in config flow tests A-M (#114681)
This commit is contained in:
parent
a767530970
commit
b9281327c4
111 changed files with 997 additions and 961 deletions
|
@ -16,6 +16,7 @@ from homeassistant.components.coinbase.const import (
|
|||
)
|
||||
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .common import (
|
||||
init_mock_coinbase,
|
||||
|
@ -32,7 +33,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
|
@ -59,7 +60,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Test User"
|
||||
assert result2["data"] == {CONF_API_KEY: "123456", CONF_API_TOKEN: "AbCDeF"}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
@ -95,7 +96,7 @@ async def test_form_invalid_auth(
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
assert "Coinbase rejected API credentials due to an unknown error" in caplog.text
|
||||
|
||||
|
@ -117,7 +118,7 @@ async def test_form_invalid_auth(
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth_key"}
|
||||
assert "Coinbase rejected API credentials due to an invalid API key" in caplog.text
|
||||
|
||||
|
@ -139,7 +140,7 @@ async def test_form_invalid_auth(
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth_secret"}
|
||||
assert (
|
||||
"Coinbase rejected API credentials due to an invalid API secret" in caplog.text
|
||||
|
@ -164,7 +165,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
|
@ -186,7 +187,7 @@ async def test_form_catch_all_exception(hass: HomeAssistant) -> None:
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
|
@ -219,7 +220,7 @@ async def test_option_form(hass: HomeAssistant) -> None:
|
|||
CONF_EXCHANGE_PRECISION: 5,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_update_listener.mock_calls) == 1
|
||||
|
||||
|
@ -249,7 +250,7 @@ async def test_form_bad_account_currency(hass: HomeAssistant) -> None:
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "currency_unavailable"}
|
||||
|
||||
|
||||
|
@ -277,7 +278,7 @@ async def test_form_bad_exchange_rate(hass: HomeAssistant) -> None:
|
|||
CONF_EXCHANGE_PRECISION: 5,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "exchange_rate_unavailable"}
|
||||
|
||||
|
||||
|
@ -311,5 +312,5 @@ async def test_option_catch_all_exception(hass: HomeAssistant) -> None:
|
|||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue