33from types import MappingProxyType
44from unittest .mock import patch
55
6- from homeassistant import config_entries , data_entry_flow
7- from homeassistant .components import dhcp
6+ from homeassistant import config_entries
7+ from homeassistant .data_entry_flow import FlowResultType
8+ from homeassistant .helpers .service_info import dhcp
89from homeassistant .core import HomeAssistant
910import pytest
1011from pytest_homeassistant_custom_component .common import MockConfigEntry
@@ -59,7 +60,7 @@ async def test_successful_config_flow(hass, bypass_get_data):
5960 )
6061
6162 # Check that the config flow shows the user form as the first step
62- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
63+ assert result ["type" ] == FlowResultType . FORM
6364 assert result ["step_id" ] == "user"
6465
6566 # If a user were to enter `test_username` for username and `test_password`
@@ -70,7 +71,7 @@ async def test_successful_config_flow(hass, bypass_get_data):
7071
7172 # Check that the config flow is complete and a new entry is created with
7273 # the input data
73- assert result ["type" ] == data_entry_flow . RESULT_TYPE_CREATE_ENTRY
74+ assert result ["type" ] == FlowResultType . CREATE_ENTRY
7475 assert result ["title" ] == "test@example.com"
7576 assert result ["data" ] == MOCK_CONFIG
7677 assert result ["result" ]
@@ -86,12 +87,14 @@ async def test_reauth_config_flow(hass, bypass_get_data):
8687 entry .add_to_hass (hass )
8788
8889 # Initialize a config flow
89- result = await hass .config_entries .flow .async_init (
90- DOMAIN , context = {"source" : config_entries .SOURCE_REAUTH }
91- )
90+ entry .async_start_reauth (hass )
91+ await hass .async_block_till_done ()
92+ flows = hass .config_entries .flow .async_progress ()
93+ assert len (flows ) == 1
94+ result = flows [0 ]
9295
9396 # Check that the config flow shows the reauth form as the first step
94- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
97+ # assert result["type"] == FlowResultType.FORM
9598 assert result ["step_id" ] == "reauth_confirm"
9699
97100 # If a user were to confirm the re-auth start, this function call
@@ -100,7 +103,7 @@ async def test_reauth_config_flow(hass, bypass_get_data):
100103 )
101104
102105 # It should load the user form
103- assert result_2 ["type" ] == data_entry_flow . RESULT_TYPE_FORM
106+ assert result_2 ["type" ] == FlowResultType . FORM
104107 assert result_2 ["step_id" ] == "user"
105108
106109 updated_config = MOCK_CONFIG
@@ -113,7 +116,7 @@ async def test_reauth_config_flow(hass, bypass_get_data):
113116
114117 # Check that the config flow is complete and a new entry is created with
115118 # the input data
116- assert result_3 ["type" ] == data_entry_flow . RESULT_TYPE_CREATE_ENTRY
119+ assert result_3 ["type" ] == FlowResultType . CREATE_ENTRY
117120 assert result_3 ["title" ] == "test@example.com"
118121 assert result_3 ["data" ] == MOCK_CONFIG
119122 assert result_3 ["result" ]
@@ -130,14 +133,14 @@ async def test_failed_config_flow(hass, error_on_get_data):
130133 DOMAIN , context = {"source" : config_entries .SOURCE_USER }
131134 )
132135
133- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
136+ assert result ["type" ] == FlowResultType . FORM
134137 assert result ["step_id" ] == "user"
135138
136139 result = await hass .config_entries .flow .async_configure (
137140 result ["flow_id" ], user_input = MOCK_CONFIG
138141 )
139142
140- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
143+ assert result ["type" ] == FlowResultType . FORM
141144 assert result ["errors" ] == {"base" : "auth" }
142145
143146
@@ -154,7 +157,7 @@ async def test_options_flow(hass, bypass_get_data):
154157 result = await hass .config_entries .options .async_init (entry .entry_id )
155158
156159 # Verify that the first options step is a user form
157- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
160+ assert result ["type" ] == FlowResultType . FORM
158161 assert result ["step_id" ] == "user"
159162
160163 # Enter some fake data into the form
@@ -164,7 +167,7 @@ async def test_options_flow(hass, bypass_get_data):
164167 )
165168
166169 # Verify that the flow finishes
167- assert result ["type" ] == data_entry_flow . RESULT_TYPE_CREATE_ENTRY
170+ assert result ["type" ] == FlowResultType . CREATE_ENTRY
168171 assert result ["title" ] == "test@example.com"
169172
170173 # Verify that the options were updated
@@ -190,7 +193,7 @@ async def test_dhcp_flow(hass: HomeAssistant, bypass_get_data) -> None:
190193 data = DHCP_SERVICE_INFO ,
191194 context = {"source" : config_entries .SOURCE_DHCP },
192195 )
193- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
196+ assert result ["type" ] == FlowResultType . FORM
194197 assert result ["step_id" ] == "user"
195198
196199 result2 = await hass .config_entries .flow .async_configure (
@@ -209,7 +212,7 @@ async def test_dhcp_login_error(hass: HomeAssistant, bypass_get_data) -> None:
209212 data = DHCP_SERVICE_INFO ,
210213 context = {"source" : config_entries .SOURCE_DHCP },
211214 )
212- assert result ["type" ] == data_entry_flow . RESULT_TYPE_FORM
215+ assert result ["type" ] == FlowResultType . FORM
213216 assert result ["step_id" ] == "user"
214217 with patch (
215218 "podpointclient.client.PodPointClient.async_credentials_verified" ,
0 commit comments