@@ -41,13 +41,13 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
41
41
result3 = await hass .config_entries .flow .async_configure (
42
42
result2 ["flow_id" ],
43
43
{
44
- CONF_PROVINCE : "BW " ,
44
+ CONF_PROVINCE : "Baden-Württemberg " ,
45
45
},
46
46
)
47
47
await hass .async_block_till_done ()
48
48
49
49
assert result3 ["type" ] is FlowResultType .CREATE_ENTRY
50
- assert result3 ["title" ] == "Germany, BW "
50
+ assert result3 ["title" ] == "Germany, Baden-Württemberg "
51
51
assert result3 ["data" ] == {
52
52
"country" : "DE" ,
53
53
"province" : "BW" ,
@@ -172,13 +172,13 @@ async def test_form_babel_unresolved_language(hass: HomeAssistant) -> None:
172
172
result = await hass .config_entries .flow .async_configure (
173
173
result ["flow_id" ],
174
174
{
175
- CONF_PROVINCE : "BW " ,
175
+ CONF_PROVINCE : "Baden-Württemberg " ,
176
176
},
177
177
)
178
178
await hass .async_block_till_done ()
179
179
180
180
assert result ["type" ] is FlowResultType .CREATE_ENTRY
181
- assert result ["title" ] == "Germany, BW "
181
+ assert result ["title" ] == "Germany, Baden-Württemberg "
182
182
assert result ["data" ] == {
183
183
"country" : "DE" ,
184
184
"province" : "BW" ,
@@ -219,13 +219,13 @@ async def test_form_babel_replace_dash_with_underscore(hass: HomeAssistant) -> N
219
219
result = await hass .config_entries .flow .async_configure (
220
220
result ["flow_id" ],
221
221
{
222
- CONF_PROVINCE : "BW " ,
222
+ CONF_PROVINCE : "Baden-Württemberg " ,
223
223
},
224
224
)
225
225
await hass .async_block_till_done ()
226
226
227
227
assert result ["type" ] is FlowResultType .CREATE_ENTRY
228
- assert result ["title" ] == "Germany, BW "
228
+ assert result ["title" ] == "Germany, Baden-Württemberg "
229
229
assert result ["data" ] == {
230
230
"country" : "DE" ,
231
231
"province" : "BW" ,
@@ -237,7 +237,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None:
237
237
"""Test reconfigure flow."""
238
238
entry = MockConfigEntry (
239
239
domain = DOMAIN ,
240
- title = "Germany, BW " ,
240
+ title = "Germany, Baden-Württemberg " ,
241
241
data = {"country" : "DE" , "province" : "BW" },
242
242
)
243
243
entry .add_to_hass (hass )
@@ -248,15 +248,15 @@ async def test_reconfigure(hass: HomeAssistant) -> None:
248
248
result = await hass .config_entries .flow .async_configure (
249
249
result ["flow_id" ],
250
250
{
251
- CONF_PROVINCE : "NW " ,
251
+ CONF_PROVINCE : "Nordrhein-Westfalen " ,
252
252
},
253
253
)
254
254
await hass .async_block_till_done ()
255
255
256
256
assert result ["type" ] is FlowResultType .ABORT
257
257
assert result ["reason" ] == "reconfigure_successful"
258
258
entry = hass .config_entries .async_get_entry (entry .entry_id )
259
- assert entry .title == "Germany, NW "
259
+ assert entry .title == "Germany, Nordrhein-Westfalen "
260
260
assert entry .data == {"country" : "DE" , "province" : "NW" }
261
261
262
262
@@ -297,7 +297,7 @@ async def test_reconfigure_incorrect_language(hass: HomeAssistant) -> None:
297
297
298
298
entry = MockConfigEntry (
299
299
domain = DOMAIN ,
300
- title = "Germany, BW " ,
300
+ title = "Germany, Baden-Württemberg " ,
301
301
data = {"country" : "DE" , "province" : "BW" },
302
302
)
303
303
entry .add_to_hass (hass )
@@ -308,15 +308,15 @@ async def test_reconfigure_incorrect_language(hass: HomeAssistant) -> None:
308
308
result = await hass .config_entries .flow .async_configure (
309
309
result ["flow_id" ],
310
310
{
311
- CONF_PROVINCE : "NW " ,
311
+ CONF_PROVINCE : "Nordrhein-Westfalen " ,
312
312
},
313
313
)
314
314
await hass .async_block_till_done ()
315
315
316
316
assert result ["type" ] is FlowResultType .ABORT
317
317
assert result ["reason" ] == "reconfigure_successful"
318
318
entry = hass .config_entries .async_get_entry (entry .entry_id )
319
- assert entry .title == "Germany, NW "
319
+ assert entry .title == "Germany, Nordrhein-Westfalen "
320
320
assert entry .data == {"country" : "DE" , "province" : "NW" }
321
321
322
322
@@ -325,13 +325,13 @@ async def test_reconfigure_entry_exists(hass: HomeAssistant) -> None:
325
325
"""Test reconfigure flow stops if other entry already exist."""
326
326
entry = MockConfigEntry (
327
327
domain = DOMAIN ,
328
- title = "Germany, BW " ,
328
+ title = "Germany, Baden-Württemberg " ,
329
329
data = {"country" : "DE" , "province" : "BW" },
330
330
)
331
331
entry .add_to_hass (hass )
332
332
entry2 = MockConfigEntry (
333
333
domain = DOMAIN ,
334
- title = "Germany, NW " ,
334
+ title = "Germany, Nordrhein-Westfalen " ,
335
335
data = {"country" : "DE" , "province" : "NW" },
336
336
)
337
337
entry2 .add_to_hass (hass )
@@ -342,15 +342,15 @@ async def test_reconfigure_entry_exists(hass: HomeAssistant) -> None:
342
342
result = await hass .config_entries .flow .async_configure (
343
343
result ["flow_id" ],
344
344
{
345
- CONF_PROVINCE : "NW " ,
345
+ CONF_PROVINCE : "Nordrhein-Westfalen " ,
346
346
},
347
347
)
348
348
await hass .async_block_till_done ()
349
349
350
350
assert result ["type" ] is FlowResultType .ABORT
351
351
assert result ["reason" ] == "already_configured"
352
352
entry = hass .config_entries .async_get_entry (entry .entry_id )
353
- assert entry .title == "Germany, BW "
353
+ assert entry .title == "Germany, Baden-Württemberg "
354
354
assert entry .data == {"country" : "DE" , "province" : "BW" }
355
355
356
356
@@ -425,6 +425,41 @@ async def test_form_with_options(
425
425
assert state .state == STATE_OFF
426
426
427
427
428
+ async def test_form_with_subdivision_aliases (hass : HomeAssistant ) -> None :
429
+ """Test the flow with several aliases using the same subdivision code."""
430
+ await hass .config .async_set_time_zone ("Europe/Paris" )
431
+
432
+ result = await hass .config_entries .flow .async_init (
433
+ DOMAIN , context = {"source" : config_entries .SOURCE_USER }
434
+ )
435
+ assert result ["type" ] is FlowResultType .FORM
436
+
437
+ result = await hass .config_entries .flow .async_configure (
438
+ result ["flow_id" ],
439
+ {
440
+ CONF_COUNTRY : "FR" ,
441
+ },
442
+ )
443
+ await hass .async_block_till_done ()
444
+
445
+ assert result ["type" ] is FlowResultType .FORM
446
+
447
+ result = await hass .config_entries .flow .async_configure (
448
+ result ["flow_id" ],
449
+ {
450
+ CONF_PROVINCE : "Alsace" ,
451
+ },
452
+ )
453
+ await hass .async_block_till_done (wait_background_tasks = True )
454
+
455
+ assert result ["type" ] is FlowResultType .CREATE_ENTRY
456
+ assert result ["title" ] == "France, Alsace"
457
+ assert result ["data" ] == {
458
+ CONF_COUNTRY : "FR" ,
459
+ CONF_PROVINCE : "GES" ,
460
+ }
461
+
462
+
428
463
@pytest .mark .usefixtures ("mock_setup_entry" )
429
464
async def test_options_abort_no_categories (hass : HomeAssistant ) -> None :
430
465
"""Test the options flow abort if no categories to select."""
0 commit comments