Skip to content

Commit dbfdaf6

Browse files
authored
Use is over == comparison for FlowResultType in flow tests (home-assistant#159158)
1 parent 278cb4d commit dbfdaf6

File tree

52 files changed

+215
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+215
-215
lines changed

tests/auth/providers/test_trusted_networks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def test_login_flow(
267267
# not from trusted network
268268
flow = await provider.async_login_flow({"ip_address": ip_address("127.0.0.1")})
269269
step = await flow.async_step_init()
270-
assert step["type"] == FlowResultType.ABORT
270+
assert step["type"] is FlowResultType.ABORT
271271
assert step["reason"] == "not_allowed"
272272

273273
# from trusted network, list users
@@ -282,7 +282,7 @@ async def test_login_flow(
282282

283283
# login with valid user
284284
step = await flow.async_step_init({"user": user.id})
285-
assert step["type"] == FlowResultType.CREATE_ENTRY
285+
assert step["type"] is FlowResultType.CREATE_ENTRY
286286
assert step["data"]["user"] == user.id
287287

288288

@@ -309,7 +309,7 @@ async def test_trusted_users_login(
309309
{"ip_address": ip_address("127.0.0.1")}
310310
)
311311
step = await flow.async_step_init()
312-
assert step["type"] == FlowResultType.ABORT
312+
assert step["type"] is FlowResultType.ABORT
313313
assert step["reason"] == "not_allowed"
314314

315315
# from trusted network, list users intersect trusted_users
@@ -396,7 +396,7 @@ async def test_trusted_group_login(
396396
{"ip_address": ip_address("127.0.0.1")}
397397
)
398398
step = await flow.async_step_init()
399-
assert step["type"] == FlowResultType.ABORT
399+
assert step["type"] is FlowResultType.ABORT
400400
assert step["reason"] == "not_allowed"
401401

402402
# from trusted network, list users intersect trusted_users
@@ -437,15 +437,15 @@ async def test_bypass_login_flow(
437437
{"ip_address": ip_address("127.0.0.1")}
438438
)
439439
step = await flow.async_step_init()
440-
assert step["type"] == FlowResultType.ABORT
440+
assert step["type"] is FlowResultType.ABORT
441441
assert step["reason"] == "not_allowed"
442442

443443
# from trusted network, only one available user, bypass the login flow
444444
flow = await provider_bypass_login.async_login_flow(
445445
{"ip_address": ip_address("192.168.0.1")}
446446
)
447447
step = await flow.async_step_init()
448-
assert step["type"] == FlowResultType.CREATE_ENTRY
448+
assert step["type"] is FlowResultType.CREATE_ENTRY
449449
assert step["data"]["user"] == owner.id
450450

451451
user = await manager_bypass_login.async_create_user("test-user")

tests/components/actron_air/test_config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ async def test_user_flow_duplicate_account(
174174
result = await hass.config_entries.flow.async_configure(result["flow_id"])
175175

176176
# Should abort because the account is already configured
177-
assert result["type"] == FlowResultType.ABORT
177+
assert result["type"] is FlowResultType.ABORT
178178
assert result["reason"] == "already_configured"
179179

180180

tests/components/airq/test_config_flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ async def test_options_flow(hass: HomeAssistant, user_input) -> None:
119119

120120
result = await hass.config_entries.options.async_init(entry.entry_id)
121121

122-
assert result["type"] == FlowResultType.FORM
122+
assert result["type"] is FlowResultType.FORM
123123
assert result["step_id"] == "init"
124124
assert entry.options == {}
125125

126126
result = await hass.config_entries.options.async_configure(
127127
result["flow_id"], user_input=user_input
128128
)
129129

130-
assert result["type"] == FlowResultType.CREATE_ENTRY
130+
assert result["type"] is FlowResultType.CREATE_ENTRY
131131
assert result["data"] == entry.options == DEFAULT_OPTIONS | user_input

tests/components/ambient_network/test_config_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def test_happy_path(
2828
setup_result = await hass.config_entries.flow.async_init(
2929
DOMAIN, context={"source": SOURCE_USER}
3030
)
31-
assert setup_result["type"] == FlowResultType.FORM
31+
assert setup_result["type"] is FlowResultType.FORM
3232
assert setup_result["step_id"] == "user"
3333

3434
with patch.object(
@@ -41,7 +41,7 @@ async def test_happy_path(
4141
{"location": {"latitude": 10.0, "longitude": 20.0, "radius": 1.0}},
4242
)
4343

44-
assert user_result["type"] == FlowResultType.FORM
44+
assert user_result["type"] is FlowResultType.FORM
4545
assert user_result["step_id"] == "station"
4646

4747
stations_result = await hass.config_entries.flow.async_configure(
@@ -51,7 +51,7 @@ async def test_happy_path(
5151
},
5252
)
5353

54-
assert stations_result["type"] == FlowResultType.CREATE_ENTRY
54+
assert stations_result["type"] is FlowResultType.CREATE_ENTRY
5555
assert stations_result["title"] == config_entry.title
5656
assert stations_result["data"] == config_entry.data
5757
assert len(mock_setup_entry.mock_calls) == 1
@@ -67,7 +67,7 @@ async def test_no_station_found(
6767
setup_result = await hass.config_entries.flow.async_init(
6868
DOMAIN, context={"source": SOURCE_USER}
6969
)
70-
assert setup_result["type"] == FlowResultType.FORM
70+
assert setup_result["type"] is FlowResultType.FORM
7171
assert setup_result["step_id"] == "user"
7272

7373
with patch.object(
@@ -80,6 +80,6 @@ async def test_no_station_found(
8080
{"location": {"latitude": 10.0, "longitude": 20.0, "radius": 1.0}},
8181
)
8282

83-
assert user_result["type"] == FlowResultType.FORM
83+
assert user_result["type"] is FlowResultType.FORM
8484
assert user_result["step_id"] == "user"
8585
assert user_result["errors"] == {"base": "no_stations_found"}

tests/components/anova/test_config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def test_flow_user(hass: HomeAssistant, anova_api: AnovaApi) -> None:
2323
result["flow_id"],
2424
user_input=CONF_INPUT,
2525
)
26-
assert result["type"] == FlowResultType.CREATE_ENTRY
26+
assert result["type"] is FlowResultType.CREATE_ENTRY
2727
assert result["data"] == {
2828
CONF_USERNAME: "[email protected]",
2929
CONF_PASSWORD: "sample",

tests/components/anthropic/test_config_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ async def test_subentry_web_search_user_location(
263263
"recommended": False,
264264
},
265265
)
266-
assert options["type"] == FlowResultType.FORM
266+
assert options["type"] is FlowResultType.FORM
267267
assert options["step_id"] == "advanced"
268268

269269
# Configure advanced step
@@ -274,7 +274,7 @@ async def test_subentry_web_search_user_location(
274274
"chat_model": "claude-sonnet-4-5",
275275
},
276276
)
277-
assert options["type"] == FlowResultType.FORM
277+
assert options["type"] is FlowResultType.FORM
278278
assert options["step_id"] == "model"
279279

280280
hass.config.country = "US"
@@ -354,7 +354,7 @@ async def test_model_list(
354354
"recommended": False,
355355
},
356356
)
357-
assert options["type"] == FlowResultType.FORM
357+
assert options["type"] is FlowResultType.FORM
358358
assert options["step_id"] == "advanced"
359359
assert options["data_schema"].schema["chat_model"].config["options"] == [
360360
{
@@ -429,7 +429,7 @@ async def test_model_list_error(
429429
"recommended": False,
430430
},
431431
)
432-
assert options["type"] == FlowResultType.FORM
432+
assert options["type"] is FlowResultType.FORM
433433
assert options["step_id"] == "advanced"
434434
assert options["data_schema"].schema["chat_model"].config["options"] == []
435435

@@ -634,7 +634,7 @@ async def test_subentry_options_switching(
634634
assert subentry_flow["step_id"] == "init"
635635

636636
for step_options in new_options:
637-
assert subentry_flow["type"] == FlowResultType.FORM
637+
assert subentry_flow["type"] is FlowResultType.FORM
638638
assert not subentry_flow["errors"]
639639

640640
# Test that current options are showed as suggested values:

tests/components/compit/test_config_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def test_async_step_user_success(
3535
result["flow_id"], CONFIG_INPUT
3636
)
3737

38-
assert result["type"] == FlowResultType.CREATE_ENTRY
38+
assert result["type"] is FlowResultType.CREATE_ENTRY
3939
assert result["title"] == CONFIG_INPUT[CONF_EMAIL]
4040
assert result["data"] == CONFIG_INPUT
4141
assert len(mock_setup_entry.mock_calls) == 1
@@ -70,14 +70,14 @@ async def test_async_step_user_failed_auth(
7070
result["flow_id"], CONFIG_INPUT
7171
)
7272

73-
assert result["type"] == FlowResultType.FORM
73+
assert result["type"] is FlowResultType.FORM
7474
assert result["errors"] == {"base": expected_error}
7575

7676
# Test success after error is cleared
7777
result = await hass.config_entries.flow.async_configure(
7878
result["flow_id"], CONFIG_INPUT
7979
)
80-
assert result["type"] == FlowResultType.CREATE_ENTRY
80+
assert result["type"] is FlowResultType.CREATE_ENTRY
8181
assert result["title"] == CONFIG_INPUT[CONF_EMAIL]
8282
assert result["data"] == CONFIG_INPUT
8383
assert len(mock_setup_entry.mock_calls) == 1

tests/components/config/test_config_entries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ async def async_step_import(
10281028
"test", context={"source": core_ce.SOURCE_IMPORT}, data={}
10291029
)
10301030

1031-
assert result["type"] == FlowResultType.CREATE_ENTRY
1031+
assert result["type"] is FlowResultType.CREATE_ENTRY
10321032
assert len(subscription_mock.mock_calls) == 0
10331033

10341034

tests/components/cookidoo/test_config_flow.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def test_flow_user_success(
4747
user_input=MOCK_DATA_USER_STEP,
4848
)
4949

50-
assert result["type"] == FlowResultType.FORM
50+
assert result["type"] is FlowResultType.FORM
5151
assert result["step_id"] == "language"
5252

5353
result = await hass.config_entries.flow.async_configure(
@@ -97,7 +97,7 @@ async def test_flow_user_init_data_unknown_error_and_recover_on_step_1(
9797
user_input=MOCK_DATA_USER_STEP,
9898
)
9999

100-
assert result["type"] == FlowResultType.FORM
100+
assert result["type"] is FlowResultType.FORM
101101
assert result["step_id"] == "language"
102102

103103
result = await hass.config_entries.flow.async_configure(
@@ -137,7 +137,7 @@ async def test_flow_user_init_data_unknown_error_and_recover_on_step_2(
137137
user_input=MOCK_DATA_USER_STEP,
138138
)
139139

140-
assert result["type"] == FlowResultType.FORM
140+
assert result["type"] is FlowResultType.FORM
141141
assert result["step_id"] == "language"
142142

143143
result = await hass.config_entries.flow.async_configure(
@@ -269,7 +269,7 @@ async def test_flow_reconfigure_init_data_unknown_error_and_recover_on_step_1(
269269
user_input={**MOCK_DATA_USER_STEP, CONF_COUNTRY: "DE"},
270270
)
271271

272-
assert result["type"] == FlowResultType.FORM
272+
assert result["type"] is FlowResultType.FORM
273273
assert result["step_id"] == "language"
274274

275275
result = await hass.config_entries.flow.async_configure(
@@ -318,7 +318,7 @@ async def test_flow_reconfigure_init_data_unknown_error_and_recover_on_step_2(
318318
user_input={**MOCK_DATA_USER_STEP, CONF_COUNTRY: "DE"},
319319
)
320320

321-
assert result["type"] == FlowResultType.FORM
321+
assert result["type"] is FlowResultType.FORM
322322
assert result["step_id"] == "language"
323323

324324
result = await hass.config_entries.flow.async_configure(

tests/components/datadog/test_config_flow.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ async def test_user_flow_success(hass: HomeAssistant) -> None:
2424
result = await hass.config_entries.flow.async_init(
2525
datadog.DOMAIN, context={"source": SOURCE_USER}
2626
)
27-
assert result["type"] == FlowResultType.FORM
27+
assert result["type"] is FlowResultType.FORM
2828

2929
result2 = await hass.config_entries.flow.async_configure(
3030
result["flow_id"], user_input=MOCK_CONFIG
3131
)
3232
assert result2["title"] == f"Datadog {MOCK_CONFIG['host']}"
33-
assert result2["type"] == FlowResultType.CREATE_ENTRY
33+
assert result2["type"] is FlowResultType.CREATE_ENTRY
3434
assert result2["data"] == MOCK_DATA
3535
assert result2["options"] == MOCK_OPTIONS
3636

@@ -48,7 +48,7 @@ async def test_user_flow_retry_after_connection_fail(hass: HomeAssistant) -> Non
4848
result2 = await hass.config_entries.flow.async_configure(
4949
result["flow_id"], user_input=MOCK_CONFIG
5050
)
51-
assert result2["type"] == FlowResultType.FORM
51+
assert result2["type"] is FlowResultType.FORM
5252
assert result2["errors"] == {"base": "cannot_connect"}
5353

5454
with patch(
@@ -57,7 +57,7 @@ async def test_user_flow_retry_after_connection_fail(hass: HomeAssistant) -> Non
5757
result3 = await hass.config_entries.flow.async_configure(
5858
result["flow_id"], user_input=MOCK_CONFIG
5959
)
60-
assert result3["type"] == FlowResultType.CREATE_ENTRY
60+
assert result3["type"] is FlowResultType.CREATE_ENTRY
6161
assert result3["data"] == MOCK_DATA
6262
assert result3["options"] == MOCK_OPTIONS
6363

@@ -104,13 +104,13 @@ async def test_options_flow_cannot_connect(hass: HomeAssistant) -> None:
104104
side_effect=OSError("connection failed"),
105105
):
106106
result = await hass.config_entries.options.async_init(mock_entry.entry_id)
107-
assert result["type"] == FlowResultType.FORM
107+
assert result["type"] is FlowResultType.FORM
108108

109109
result2 = await hass.config_entries.options.async_configure(
110110
result["flow_id"], user_input=MOCK_OPTIONS
111111
)
112112

113-
assert result2["type"] == FlowResultType.FORM
113+
assert result2["type"] is FlowResultType.FORM
114114
assert result2["errors"] == {"base": "cannot_connect"}
115115

116116
with patch(
@@ -119,7 +119,7 @@ async def test_options_flow_cannot_connect(hass: HomeAssistant) -> None:
119119
result3 = await hass.config_entries.options.async_configure(
120120
result["flow_id"], user_input=MOCK_OPTIONS
121121
)
122-
assert result3["type"] == FlowResultType.CREATE_ENTRY
122+
assert result3["type"] is FlowResultType.CREATE_ENTRY
123123
assert result3["data"] == MOCK_OPTIONS
124124

125125

@@ -141,7 +141,7 @@ async def test_import_flow(
141141
data=MOCK_CONFIG,
142142
)
143143

144-
assert result["type"] == FlowResultType.CREATE_ENTRY
144+
assert result["type"] is FlowResultType.CREATE_ENTRY
145145
assert result["data"] == MOCK_DATA
146146
assert result["options"] == MOCK_OPTIONS
147147

@@ -200,11 +200,11 @@ async def test_options_flow(hass: HomeAssistant) -> None:
200200
side_effect=OSError,
201201
):
202202
result = await hass.config_entries.options.async_init(mock_entry.entry_id)
203-
assert result["type"] == FlowResultType.FORM
203+
assert result["type"] is FlowResultType.FORM
204204
result2 = await hass.config_entries.options.async_configure(
205205
result["flow_id"], user_input=new_options
206206
)
207-
assert result2["type"] == FlowResultType.FORM
207+
assert result2["type"] is FlowResultType.FORM
208208
assert result2["errors"] == {"base": "cannot_connect"}
209209

210210
# ValueError Case
@@ -213,11 +213,11 @@ async def test_options_flow(hass: HomeAssistant) -> None:
213213
side_effect=ValueError,
214214
):
215215
result = await hass.config_entries.options.async_init(mock_entry.entry_id)
216-
assert result["type"] == FlowResultType.FORM
216+
assert result["type"] is FlowResultType.FORM
217217
result2 = await hass.config_entries.options.async_configure(
218218
result["flow_id"], user_input=new_options
219219
)
220-
assert result2["type"] == FlowResultType.FORM
220+
assert result2["type"] is FlowResultType.FORM
221221
assert result2["errors"] == {"base": "cannot_connect"}
222222

223223
# Success Case
@@ -231,7 +231,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
231231
result["flow_id"], user_input=new_options
232232
)
233233

234-
assert result["type"] == FlowResultType.CREATE_ENTRY
234+
assert result["type"] is FlowResultType.CREATE_ENTRY
235235
assert result["data"] == new_options
236236
mock_instance.increment.assert_called_once_with("connection_test")
237237

@@ -253,5 +253,5 @@ async def test_import_flow_abort_already_configured_service(
253253
data=MOCK_CONFIG,
254254
)
255255

256-
assert result["type"] == FlowResultType.ABORT
256+
assert result["type"] is FlowResultType.ABORT
257257
assert result["reason"] == "already_configured"

0 commit comments

Comments
 (0)