@@ -364,8 +364,8 @@ async def consume_progress_flow(
364364 return result
365365
366366
367- async def test_config_flow_recommended (hass : HomeAssistant ) -> None :
368- """Test the config flow with recommended installation type for Zigbee ."""
367+ async def test_config_flow_zigbee_recommended (hass : HomeAssistant ) -> None :
368+ """Test flow with recommended Zigbee installation type."""
369369 init_result = await hass .config_entries .flow .async_init (
370370 TEST_DOMAIN , context = {"source" : "hardware" }
371371 )
@@ -418,37 +418,28 @@ async def test_config_flow_recommended(hass: HomeAssistant) -> None:
418418 assert zha_flow ["context" ]["source" ] == "hardware"
419419 assert zha_flow ["step_id" ] == "confirm"
420420
421+ progress_zha_flows = hass .config_entries .flow ._async_progress_by_handler (
422+ handler = "zha" ,
423+ match_context = None ,
424+ )
421425
422- @pytest .mark .parametrize (
423- ("zigbee_integration" , "zha_flows" ),
424- [
425- (
426- "zigbee_integration_zha" ,
427- [
428- {
429- "context" : {
430- "confirm_only" : True ,
431- "source" : "hardware" ,
432- "title_placeholders" : {
433- "name" : "Some Hardware Name" ,
434- },
435- "unique_id" : "Some Hardware Name_ezsp_/dev/SomeDevice123" ,
436- },
437- "flow_id" : ANY ,
438- "handler" : "zha" ,
439- "step_id" : "confirm" ,
440- }
441- ],
442- ),
443- ("zigbee_integration_other" , []),
444- ],
445- )
446- async def test_config_flow_zigbee_custom (
447- hass : HomeAssistant ,
448- zigbee_integration : str ,
449- zha_flows : list [ConfigFlowResult ],
450- ) -> None :
451- """Test the config flow with custom installation type selected for Zigbee."""
426+ assert len (progress_zha_flows ) == 1
427+
428+ progress_zha_flow = progress_zha_flows [0 ]
429+ assert progress_zha_flow .init_data == {
430+ "name" : "Some Hardware Name" ,
431+ "port" : {
432+ "path" : "/dev/SomeDevice123" ,
433+ "baudrate" : 115200 ,
434+ "flow_control" : "hardware" ,
435+ },
436+ "radio_type" : "ezsp" ,
437+ "flow_strategy" : "recommended" ,
438+ }
439+
440+
441+ async def test_config_flow_zigbee_custom_zha (hass : HomeAssistant ) -> None :
442+ """Test flow with custom Zigbee installation type and ZHA selected."""
452443 init_result = await hass .config_entries .flow .async_init (
453444 TEST_DOMAIN , context = {"source" : "hardware" }
454445 )
@@ -479,7 +470,7 @@ async def test_config_flow_zigbee_custom(
479470
480471 pick_result = await hass .config_entries .flow .async_configure (
481472 pick_result ["flow_id" ],
482- user_input = {"next_step_id" : zigbee_integration },
473+ user_input = {"next_step_id" : "zigbee_integration_zha" },
483474 )
484475
485476 assert pick_result ["type" ] is FlowResultType .SHOW_PROGRESS
@@ -503,7 +494,98 @@ async def test_config_flow_zigbee_custom(
503494
504495 # Ensure a ZHA discovery flow has been created
505496 flows = hass .config_entries .flow .async_progress ()
506- assert flows == zha_flows
497+ assert flows == [
498+ {
499+ "context" : {
500+ "confirm_only" : True ,
501+ "source" : "hardware" ,
502+ "title_placeholders" : {
503+ "name" : "Some Hardware Name" ,
504+ },
505+ "unique_id" : "Some Hardware Name_ezsp_/dev/SomeDevice123" ,
506+ },
507+ "flow_id" : ANY ,
508+ "handler" : "zha" ,
509+ "step_id" : "confirm" ,
510+ }
511+ ]
512+
513+ progress_zha_flows = hass .config_entries .flow ._async_progress_by_handler (
514+ handler = "zha" ,
515+ match_context = None ,
516+ )
517+
518+ assert len (progress_zha_flows ) == 1
519+
520+ progress_zha_flow = progress_zha_flows [0 ]
521+ assert progress_zha_flow .init_data == {
522+ "name" : "Some Hardware Name" ,
523+ "port" : {
524+ "path" : "/dev/SomeDevice123" ,
525+ "baudrate" : 115200 ,
526+ "flow_control" : "hardware" ,
527+ },
528+ "radio_type" : "ezsp" ,
529+ "flow_strategy" : "advanced" ,
530+ }
531+
532+
533+ async def test_config_flow_zigbee_custom_other (hass : HomeAssistant ) -> None :
534+ """Test flow with custom Zigbee installation type and Other selected."""
535+ init_result = await hass .config_entries .flow .async_init (
536+ TEST_DOMAIN , context = {"source" : "hardware" }
537+ )
538+
539+ assert init_result ["type" ] is FlowResultType .MENU
540+ assert init_result ["step_id" ] == "pick_firmware"
541+
542+ with mock_firmware_info (
543+ probe_app_type = ApplicationType .SPINEL ,
544+ flash_app_type = ApplicationType .EZSP ,
545+ ):
546+ # Pick the menu option: we are flashing the firmware
547+ pick_result = await hass .config_entries .flow .async_configure (
548+ init_result ["flow_id" ],
549+ user_input = {"next_step_id" : STEP_PICK_FIRMWARE_ZIGBEE },
550+ )
551+
552+ assert pick_result ["type" ] is FlowResultType .MENU
553+ assert pick_result ["step_id" ] == "zigbee_installation_type"
554+
555+ pick_result = await hass .config_entries .flow .async_configure (
556+ pick_result ["flow_id" ],
557+ user_input = {"next_step_id" : "zigbee_intent_custom" },
558+ )
559+
560+ assert pick_result ["type" ] is FlowResultType .MENU
561+ assert pick_result ["step_id" ] == "zigbee_integration"
562+
563+ pick_result = await hass .config_entries .flow .async_configure (
564+ pick_result ["flow_id" ],
565+ user_input = {"next_step_id" : "zigbee_integration_other" },
566+ )
567+
568+ assert pick_result ["type" ] is FlowResultType .SHOW_PROGRESS
569+ assert pick_result ["progress_action" ] == "install_firmware"
570+ assert pick_result ["step_id" ] == "install_zigbee_firmware"
571+
572+ create_result = await consume_progress_flow (
573+ hass ,
574+ flow_id = pick_result ["flow_id" ],
575+ valid_step_ids = ("install_zigbee_firmware" ,),
576+ )
577+
578+ assert create_result ["type" ] is FlowResultType .CREATE_ENTRY
579+
580+ config_entry = create_result ["result" ]
581+ assert config_entry .data == {
582+ "firmware" : "ezsp" ,
583+ "device" : TEST_DEVICE ,
584+ "hardware" : TEST_HARDWARE_NAME ,
585+ }
586+
587+ flows = hass .config_entries .flow .async_progress ()
588+ assert flows == []
507589
508590
509591async def test_config_flow_firmware_index_download_fails_but_not_required (
0 commit comments