Skip to content

Commit 2d77233

Browse files
committed
Fix config flow tests
1 parent 46be4bf commit 2d77233

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/test_config_flow.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
from unittest.mock import patch
44

5-
from homeassistant import config_entries, data_entry_flow
5+
from homeassistant.config_entries import SOURCE_USER
66
from homeassistant.const import CONF_NAME
77
from homeassistant.core import HomeAssistant
8+
from homeassistant.data_entry_flow import FlowResultType
89
import pytest
9-
from pytest_homeassistant_custom_component.common import MockConfigEntry
1010

1111
from custom_components.knmi.const import DOMAIN
1212

@@ -27,18 +27,18 @@ def bypass_setup_fixture():
2727
yield
2828

2929

30-
# Here we simiulate a successful config flow from the backend.
30+
# Here we simulate a successful config flow from the backend.
3131
# Note that we use the `mocked_data` fixture here because
3232
# we want the config flow validation to succeed during the test.
3333
async def test_successful_config_flow(hass: HomeAssistant, mocked_data):
3434
"""Test a successful config flow."""
3535
# Initialize a config flow
3636
result = await hass.config_entries.flow.async_init(
37-
DOMAIN, context={"source": config_entries.SOURCE_USER}
37+
DOMAIN, context={"source": SOURCE_USER}
3838
)
3939

4040
# Check that the config flow shows the user form as the first step
41-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
41+
assert result["type"] == FlowResultType.FORM
4242
assert result["step_id"] == "user"
4343

4444
# If a user were to fill in all fields, it would result in this function call
@@ -48,7 +48,7 @@ async def test_successful_config_flow(hass: HomeAssistant, mocked_data):
4848

4949
# Check that the config flow is complete and a new entry is created with
5050
# the input data
51-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
51+
assert result["type"] == FlowResultType.CREATE_ENTRY
5252
assert result["title"] == MOCK_CONFIG[CONF_NAME]
5353
assert result["data"] == MOCK_CONFIG
5454
assert result["result"]
@@ -61,17 +61,17 @@ async def test_successful_config_flow(hass: HomeAssistant, mocked_data):
6161
async def test_failed_config_flow(hass: HomeAssistant, config_flow_exceptions):
6262
"""Test a failed config flow due to credential validation failure."""
6363
result = await hass.config_entries.flow.async_init(
64-
DOMAIN, context={"source": config_entries.SOURCE_USER}
64+
DOMAIN, context={"source": SOURCE_USER}
6565
)
6666

67-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
67+
assert result["type"] == FlowResultType.FORM
6868
assert result["step_id"] == "user"
6969

7070
result = await hass.config_entries.flow.async_configure(
7171
result["flow_id"], user_input=MOCK_CONFIG
7272
)
7373

74-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
74+
assert result["type"] == FlowResultType.FORM
7575
assert "base" in result["errors"]
7676

7777

@@ -86,7 +86,7 @@ async def test_options_flow(hass: HomeAssistant):
8686
result = await hass.config_entries.options.async_init(config_entry.entry_id)
8787

8888
# Verify that the first options step is a user form
89-
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
89+
assert result["type"] == FlowResultType.FORM
9090
assert result["step_id"] == "user"
9191

9292
# Enter some fake data into the form
@@ -96,7 +96,7 @@ async def test_options_flow(hass: HomeAssistant):
9696
)
9797

9898
# Verify that the flow finishes
99-
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
99+
assert result["type"] == FlowResultType.CREATE_ENTRY
100100
assert result["title"] == MOCK_CONFIG[CONF_NAME]
101101

102102
# Verify that the options were updated

0 commit comments

Comments
 (0)