1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Search/replace RESULT_TYPE_* by FlowResultType enum (#74642)

This commit is contained in:
Franck Nijhof
2022-07-07 18:57:36 +02:00
committed by GitHub
parent 68ccb96089
commit 7cd68381f1
237 changed files with 2284 additions and 2280 deletions

View File

@@ -68,7 +68,7 @@ async def test_form(hass, fakeimg_png, user_flow, mock_create_stream):
user_flow["flow_id"],
TESTDATA,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["title"] == "127_0_0_1"
assert result2["options"] == {
CONF_STILL_IMAGE_URL: "http://127.0.0.1/testurl/1",
@@ -104,7 +104,7 @@ async def test_form_only_stillimage(hass, fakeimg_png, user_flow):
data,
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["title"] == "127_0_0_1"
assert result2["options"] == {
CONF_STILL_IMAGE_URL: "http://127.0.0.1/testurl/1",
@@ -131,7 +131,7 @@ async def test_form_only_stillimage_gif(hass, fakeimg_gif, user_flow):
data,
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["options"][CONF_CONTENT_TYPE] == "image/gif"
@@ -148,7 +148,7 @@ async def test_form_only_svg_whitespace(hass, fakeimgbytes_svg, user_flow):
data,
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
@respx.mock
@@ -175,7 +175,7 @@ async def test_form_only_still_sample(hass, user_flow, image_file):
data,
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
@respx.mock
@@ -186,31 +186,31 @@ async def test_form_only_still_sample(hass, user_flow, image_file):
(
"http://localhost:812{{3}}/static/icons/favicon-apple-180x180.png",
"http://localhost:8123/static/icons/favicon-apple-180x180.png",
data_entry_flow.RESULT_TYPE_CREATE_ENTRY,
data_entry_flow.FlowResultType.CREATE_ENTRY,
None,
),
(
"{% if 1 %}https://bla{% else %}https://yo{% endif %}",
"https://bla/",
data_entry_flow.RESULT_TYPE_CREATE_ENTRY,
data_entry_flow.FlowResultType.CREATE_ENTRY,
None,
),
(
"http://{{example.org",
"http://example.org",
data_entry_flow.RESULT_TYPE_FORM,
data_entry_flow.FlowResultType.FORM,
{"still_image_url": "template_error"},
),
(
"invalid1://invalid:4\\1",
"invalid1://invalid:4%5c1",
data_entry_flow.RESULT_TYPE_FORM,
data_entry_flow.FlowResultType.FORM,
{"still_image_url": "malformed_url"},
),
(
"relative/urls/are/not/allowed.jpg",
"relative/urls/are/not/allowed.jpg",
data_entry_flow.RESULT_TYPE_FORM,
data_entry_flow.FlowResultType.FORM,
{"still_image_url": "relative_url"},
),
],
@@ -246,7 +246,7 @@ async def test_form_rtsp_mode(hass, fakeimg_png, user_flow, mock_create_stream):
user_flow["flow_id"], data
)
assert "errors" not in result2, f"errors={result2['errors']}"
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["title"] == "127_0_0_1"
assert result2["options"] == {
CONF_STILL_IMAGE_URL: "http://127.0.0.1/testurl/1",
@@ -280,7 +280,7 @@ async def test_form_only_stream(hass, fakeimgbytes_jpg, mock_create_stream):
)
await hass.async_block_till_done()
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result3["title"] == "127_0_0_1"
assert result3["options"] == {
CONF_AUTHENTICATION: HTTP_BASIC_AUTHENTICATION,
@@ -314,7 +314,7 @@ async def test_form_still_and_stream_not_provided(hass, user_flow):
CONF_VERIFY_SSL: False,
},
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["errors"] == {"base": "no_still_image_or_stream_url"}
@@ -492,7 +492,7 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(mock_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init"
# try updating the still image url
@@ -503,10 +503,10 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
result["flow_id"],
user_input=data,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
result3 = await hass.config_entries.options.async_init(mock_entry.entry_id)
assert result3["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result3["type"] == data_entry_flow.FlowResultType.FORM
assert result3["step_id"] == "init"
# verify that an invalid template reports the correct UI error.
@@ -515,7 +515,7 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
result3["flow_id"],
user_input=data,
)
assert result4.get("type") == data_entry_flow.RESULT_TYPE_FORM
assert result4.get("type") == data_entry_flow.FlowResultType.FORM
assert result4["errors"] == {"still_image_url": "template_error"}
# verify that an invalid template reports the correct UI error.
@@ -526,7 +526,7 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
user_input=data,
)
assert result5.get("type") == data_entry_flow.RESULT_TYPE_FORM
assert result5.get("type") == data_entry_flow.FlowResultType.FORM
assert result5["errors"] == {"stream_source": "template_error"}
# verify that an relative stream url is rejected.
@@ -536,7 +536,7 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
result5["flow_id"],
user_input=data,
)
assert result6.get("type") == data_entry_flow.RESULT_TYPE_FORM
assert result6.get("type") == data_entry_flow.FlowResultType.FORM
assert result6["errors"] == {"stream_source": "relative_url"}
# verify that an malformed stream url is rejected.
@@ -546,7 +546,7 @@ async def test_options_template_error(hass, fakeimgbytes_png, mock_create_stream
result6["flow_id"],
user_input=data,
)
assert result7.get("type") == data_entry_flow.RESULT_TYPE_FORM
assert result7.get("type") == data_entry_flow.FlowResultType.FORM
assert result7["errors"] == {"stream_source": "malformed_url"}
@@ -583,7 +583,7 @@ async def test_options_only_stream(hass, fakeimgbytes_png, mock_create_stream):
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(mock_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init"
# try updating the config options
@@ -592,7 +592,7 @@ async def test_options_only_stream(hass, fakeimgbytes_png, mock_create_stream):
result["flow_id"],
user_input=data,
)
assert result3["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result3["data"][CONF_CONTENT_TYPE] == "image/jpeg"
@@ -607,12 +607,12 @@ async def test_import(hass, fakeimg_png):
result2 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=TESTDATA_YAML
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["title"] == "Yaml Defined Name"
await hass.async_block_till_done()
# Any name defined in yaml should end up as the entity id.
assert hass.states.get("camera.yaml_defined_name")
assert result2["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
# These above can be deleted after deprecation period is finished.
@@ -707,7 +707,7 @@ async def test_use_wallclock_as_timestamps_option(
result = await hass.config_entries.options.async_init(
mock_entry.entry_id, context={"show_advanced_options": True}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "init"
with patch(
"homeassistant.components.generic.async_setup_entry", return_value=True
@@ -716,4 +716,4 @@ async def test_use_wallclock_as_timestamps_option(
result["flow_id"],
user_input={CONF_USE_WALLCLOCK_AS_TIMESTAMPS: True, **TESTDATA},
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY