3131)
3232from homeassistant .components .default_config import DOMAIN as DEFAULT_CONFIG_DOMAIN
3333from homeassistant .components .go2rtc import WebRTCProvider
34- from homeassistant .components .go2rtc .const import DOMAIN
34+ from homeassistant .components .go2rtc .const import (
35+ CONF_DEBUG_UI ,
36+ DEBUG_UI_URL_MESSAGE ,
37+ DOMAIN ,
38+ )
3539from homeassistant .config_entries import ConfigEntry , ConfigEntryState , ConfigFlow
3640from homeassistant .const import CONF_URL
3741from homeassistant .core import HomeAssistant
@@ -265,7 +269,15 @@ async def test() -> None:
265269 "mock_is_docker_env" ,
266270 "mock_go2rtc_entry" ,
267271)
268- @pytest .mark .parametrize ("config" , [{DOMAIN : {}}, {DEFAULT_CONFIG_DOMAIN : {}}])
272+ @pytest .mark .parametrize (
273+ ("config" , "ui_enabled" ),
274+ [
275+ ({DOMAIN : {}}, False ),
276+ ({DOMAIN : {CONF_DEBUG_UI : True }}, True ),
277+ ({DEFAULT_CONFIG_DOMAIN : {}}, False ),
278+ ({DEFAULT_CONFIG_DOMAIN : {}, DOMAIN : {CONF_DEBUG_UI : True }}, True ),
279+ ],
280+ )
269281@pytest .mark .parametrize ("has_go2rtc_entry" , [True , False ])
270282async def test_setup_go_binary (
271283 hass : HomeAssistant ,
@@ -277,12 +289,13 @@ async def test_setup_go_binary(
277289 init_test_integration : MockCamera ,
278290 has_go2rtc_entry : bool ,
279291 config : ConfigType ,
292+ ui_enabled : bool ,
280293) -> None :
281294 """Test the go2rtc config entry with binary."""
282295 assert (len (hass .config_entries .async_entries (DOMAIN )) == 1 ) == has_go2rtc_entry
283296
284297 def after_setup () -> None :
285- server .assert_called_once_with (hass , "/usr/bin/go2rtc" )
298+ server .assert_called_once_with (hass , "/usr/bin/go2rtc" , enable_ui = ui_enabled )
286299 server_start .assert_called_once ()
287300
288301 await _test_setup_and_signaling (
@@ -468,7 +481,9 @@ async def test_close_session(
468481ERR_CONNECT_RETRY = (
469482 "Could not connect to go2rtc instance on http://localhost:1984/; Retrying"
470483)
471- ERR_INVALID_URL = "Invalid config for 'go2rtc': invalid url"
484+ _INVALID_CONFIG = "Invalid config for 'go2rtc': "
485+ ERR_INVALID_URL = _INVALID_CONFIG + "invalid url"
486+ ERR_EXCLUSIVE = _INVALID_CONFIG + DEBUG_UI_URL_MESSAGE
472487ERR_URL_REQUIRED = "Go2rtc URL required in non-docker installs"
473488
474489
@@ -501,6 +516,12 @@ async def test_non_user_setup_with_error(
501516 ({DOMAIN : {}}, None , False , ERR_URL_REQUIRED ),
502517 ({DOMAIN : {}}, None , True , ERR_BINARY_NOT_FOUND ),
503518 ({DOMAIN : {CONF_URL : "invalid" }}, None , True , ERR_INVALID_URL ),
519+ (
520+ {DOMAIN : {CONF_URL : "http://localhost:1984" , CONF_DEBUG_UI : True }},
521+ None ,
522+ True ,
523+ ERR_EXCLUSIVE ,
524+ ),
504525 ],
505526)
506527@pytest .mark .parametrize ("has_go2rtc_entry" , [True , False ])
0 commit comments