77import pytest
88from wled import Device as WLEDDevice , Releases
99
10+ from homeassistant .components .wled .config_flow import CONF_KEEP_MAIN_LIGHT
1011from homeassistant .components .wled .const import DOMAIN
1112from homeassistant .const import CONF_HOST
1213from homeassistant .core import HomeAssistant
@@ -22,7 +23,7 @@ def mock_config_entry() -> MockConfigEntry:
2223 domain = DOMAIN ,
2324 data = {CONF_HOST : "192.168.1.123" },
2425 unique_id = "aabbccddeeff" ,
25- minor_version = 2 ,
26+ minor_version = 3 ,
2627 )
2728
2829
@@ -89,12 +90,19 @@ def mock_wled(
8990 yield wled
9091
9192
93+ @pytest .fixture
94+ def opt_keep_main_light () -> bool | None :
95+ """Return the conf_keep_main_light option."""
96+ return None
97+
98+
9299@pytest .fixture
93100async def init_integration (
94101 hass : HomeAssistant ,
95102 freezer : FrozenDateTimeFactory ,
96103 mock_config_entry : MockConfigEntry ,
97104 mock_wled : MagicMock ,
105+ opt_keep_main_light : bool | None ,
98106) -> MockConfigEntry :
99107 """Set up the WLED integration for testing."""
100108 mock_config_entry .add_to_hass (hass )
@@ -106,4 +114,11 @@ async def init_integration(
106114 # time by SCAN_INTERVAL
107115 freezer .tick (1 )
108116
117+ if opt_keep_main_light is not None :
118+ hass .config_entries .async_update_entry (
119+ mock_config_entry , options = {CONF_KEEP_MAIN_LIGHT : opt_keep_main_light }
120+ )
121+ await hass .config_entries .async_reload (mock_config_entry .entry_id )
122+ await hass .async_block_till_done ()
123+
109124 return mock_config_entry
0 commit comments