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
|
@ -42,7 +42,7 @@ async def test_form(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
|
@ -55,7 +55,7 @@ async def test_form(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Get Value"
|
||||
assert result2["options"] == {
|
||||
"name": "Get Value",
|
||||
|
@ -76,7 +76,7 @@ async def test_form_with_value_template(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
|
@ -89,7 +89,7 @@ async def test_form_with_value_template(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Get Value"
|
||||
assert result2["options"] == {
|
||||
"name": "Get Value",
|
||||
|
@ -107,7 +107,7 @@ async def test_flow_fails_db_url(recorder_mock: Recorder, hass: HomeAssistant) -
|
|||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result4["type"] == FlowResultType.FORM
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
with patch(
|
||||
|
@ -130,7 +130,7 @@ async def test_flow_fails_invalid_query(
|
|||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result4["type"] == FlowResultType.FORM
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
result5 = await hass.config_entries.flow.async_configure(
|
||||
|
@ -138,7 +138,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.FORM
|
||||
assert result5["type"] is FlowResultType.FORM
|
||||
assert result5["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY_2,
|
||||
)
|
||||
|
||||
assert result6["type"] == FlowResultType.FORM
|
||||
assert result6["type"] is FlowResultType.FORM
|
||||
assert result6["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY_3,
|
||||
)
|
||||
|
||||
assert result6["type"] == FlowResultType.FORM
|
||||
assert result6["type"] is FlowResultType.FORM
|
||||
assert result6["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_QUERY_NO_READ_ONLY,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.FORM
|
||||
assert result5["type"] is FlowResultType.FORM
|
||||
assert result5["errors"] == {
|
||||
"query": "query_no_read_only",
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_QUERY_NO_READ_ONLY_CTE,
|
||||
)
|
||||
|
||||
assert result6["type"] == FlowResultType.FORM
|
||||
assert result6["type"] is FlowResultType.FORM
|
||||
assert result6["errors"] == {
|
||||
"query": "query_no_read_only",
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_MULTIPLE_QUERIES,
|
||||
)
|
||||
|
||||
assert result6["type"] == FlowResultType.FORM
|
||||
assert result6["type"] is FlowResultType.FORM
|
||||
assert result6["errors"] == {
|
||||
"query": "multiple_queries",
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_NO_RESULTS,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.FORM
|
||||
assert result5["type"] is FlowResultType.FORM
|
||||
assert result5["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ async def test_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result5["title"] == "Get Value"
|
||||
assert result5["options"] == {
|
||||
"name": "Get Value",
|
||||
|
@ -228,7 +228,7 @@ async def test_flow_fails_invalid_column_name(
|
|||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result4["type"] == FlowResultType.FORM
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["step_id"] == "user"
|
||||
|
||||
result5 = await hass.config_entries.flow.async_configure(
|
||||
|
@ -236,7 +236,7 @@ async def test_flow_fails_invalid_column_name(
|
|||
user_input=ENTRY_CONFIG_INVALID_COLUMN_NAME,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.FORM
|
||||
assert result5["type"] is FlowResultType.FORM
|
||||
assert result5["errors"] == {
|
||||
"column": "column_invalid",
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ async def test_flow_fails_invalid_column_name(
|
|||
user_input=ENTRY_CONFIG,
|
||||
)
|
||||
|
||||
assert result5["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result5["title"] == "Get Value"
|
||||
assert result5["options"] == {
|
||||
"name": "Get Value",
|
||||
|
@ -284,7 +284,7 @@ async def test_options_flow(recorder_mock: Recorder, hass: HomeAssistant) -> Non
|
|||
|
||||
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"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
|
@ -300,7 +300,7 @@ async def test_options_flow(recorder_mock: Recorder, hass: HomeAssistant) -> Non
|
|||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"name": "Get Value",
|
||||
"query": "SELECT 5 as size",
|
||||
|
@ -334,7 +334,7 @@ async def test_options_flow_name_previously_removed(
|
|||
|
||||
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"
|
||||
|
||||
with patch(
|
||||
|
@ -353,7 +353,7 @@ async def test_options_flow_name_previously_removed(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"name": "Get Value Title",
|
||||
"query": "SELECT 5 as size",
|
||||
|
@ -436,7 +436,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY_OPT,
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY_2_OPT,
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_INVALID_QUERY_3_OPT,
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {
|
||||
"query": "query_invalid",
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_QUERY_NO_READ_ONLY_OPT,
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {
|
||||
"query": "query_no_read_only",
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_QUERY_NO_READ_ONLY_CTE_OPT,
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {
|
||||
"query": "query_no_read_only",
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
user_input=ENTRY_CONFIG_MULTIPLE_QUERIES_OPT,
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {
|
||||
"query": "multiple_queries",
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ async def test_options_flow_fails_invalid_query(
|
|||
},
|
||||
)
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["data"] == {
|
||||
"name": "Get Value",
|
||||
"query": "SELECT 5 as size",
|
||||
|
@ -540,7 +540,7 @@ async def test_options_flow_fails_invalid_column_name(
|
|||
user_input=ENTRY_CONFIG_INVALID_COLUMN_NAME_OPT,
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {
|
||||
"column": "column_invalid",
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ async def test_options_flow_fails_invalid_column_name(
|
|||
},
|
||||
)
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["data"] == {
|
||||
"name": "Get Value",
|
||||
"query": "SELECT 5 as value",
|
||||
|
@ -589,7 +589,7 @@ async def test_options_flow_db_url_empty(
|
|||
|
||||
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"
|
||||
|
||||
with (
|
||||
|
@ -611,7 +611,7 @@ async def test_options_flow_db_url_empty(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"name": "Get Value",
|
||||
"query": "SELECT 5 as size",
|
||||
|
@ -627,7 +627,7 @@ async def test_full_flow_not_recorder_db(
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
|
@ -650,7 +650,7 @@ async def test_full_flow_not_recorder_db(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Get Value"
|
||||
assert result2["options"] == {
|
||||
"name": "Get Value",
|
||||
|
@ -663,7 +663,7 @@ async def test_full_flow_not_recorder_db(
|
|||
|
||||
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"
|
||||
|
||||
with (
|
||||
|
@ -686,7 +686,7 @@ async def test_full_flow_not_recorder_db(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"name": "Get Value",
|
||||
"db_url": "sqlite://path/to/db.db",
|
||||
|
@ -711,7 +711,7 @@ async def test_full_flow_not_recorder_db(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"name": "Get Value",
|
||||
"db_url": "sqlite://path/to/db.db",
|
||||
|
@ -745,7 +745,7 @@ async def test_device_state_class(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
with patch(
|
||||
|
@ -764,7 +764,7 @@ async def test_device_state_class(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"name": "Get Value",
|
||||
"query": "SELECT 5 as value",
|
||||
|
@ -775,7 +775,7 @@ async def test_device_state_class(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
}
|
||||
|
||||
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"
|
||||
|
||||
with patch(
|
||||
|
@ -792,7 +792,7 @@ async def test_device_state_class(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert "device_class" not in result3["data"]
|
||||
assert "state_class" not in result3["data"]
|
||||
assert result3["data"] == {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue