Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
9c45115468
commit
fbe7b4ddfa
13 changed files with 173 additions and 63 deletions
|
@ -4,6 +4,7 @@ import unittest
|
|||
from homeassistant import setup
|
||||
from homeassistant.components import frontend
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
|
@ -26,38 +27,42 @@ class TestPanelIframe(unittest.TestCase):
|
|||
]
|
||||
|
||||
for conf in to_try:
|
||||
assert not setup.setup_component(
|
||||
self.hass, "panel_iframe", {"panel_iframe": conf}
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.http.start_http_server_and_save_config"
|
||||
):
|
||||
assert not setup.setup_component(
|
||||
self.hass, "panel_iframe", {"panel_iframe": conf}
|
||||
)
|
||||
|
||||
def test_correct_config(self):
|
||||
"""Test correct config."""
|
||||
assert setup.setup_component(
|
||||
self.hass,
|
||||
"panel_iframe",
|
||||
{
|
||||
"panel_iframe": {
|
||||
"router": {
|
||||
"icon": "mdi:network-wireless",
|
||||
"title": "Router",
|
||||
"url": "http://192.168.1.1",
|
||||
"require_admin": True,
|
||||
},
|
||||
"weather": {
|
||||
"icon": "mdi:weather",
|
||||
"title": "Weather",
|
||||
"url": "https://www.wunderground.com/us/ca/san-diego",
|
||||
"require_admin": True,
|
||||
},
|
||||
"api": {"icon": "mdi:weather", "title": "Api", "url": "/api"},
|
||||
"ftp": {
|
||||
"icon": "mdi:weather",
|
||||
"title": "FTP",
|
||||
"url": "ftp://some/ftp",
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
with patch("homeassistant.components.http.start_http_server_and_save_config"):
|
||||
assert setup.setup_component(
|
||||
self.hass,
|
||||
"panel_iframe",
|
||||
{
|
||||
"panel_iframe": {
|
||||
"router": {
|
||||
"icon": "mdi:network-wireless",
|
||||
"title": "Router",
|
||||
"url": "http://192.168.1.1",
|
||||
"require_admin": True,
|
||||
},
|
||||
"weather": {
|
||||
"icon": "mdi:weather",
|
||||
"title": "Weather",
|
||||
"url": "https://www.wunderground.com/us/ca/san-diego",
|
||||
"require_admin": True,
|
||||
},
|
||||
"api": {"icon": "mdi:weather", "title": "Api", "url": "/api"},
|
||||
"ftp": {
|
||||
"icon": "mdi:weather",
|
||||
"title": "FTP",
|
||||
"url": "ftp://some/ftp",
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
panels = self.hass.data[frontend.DATA_PANELS]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue