mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Allow specifying custom html urls to load. (#9150)
* Allow specifying custom html urls to load. * Change add_extra_html_urls to accept a single URL
This commit is contained in:
@@ -6,7 +6,8 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components.frontend import DOMAIN, ATTR_THEMES
|
||||
from homeassistant.components.frontend import (
|
||||
DOMAIN, ATTR_THEMES, ATTR_EXTRA_HTML_URL)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -30,6 +31,16 @@ def mock_http_client_with_themes(hass, test_client):
|
||||
return hass.loop.run_until_complete(test_client(hass.http.app))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_http_client_with_urls(hass, test_client):
|
||||
"""Start the Hass HTTP component."""
|
||||
hass.loop.run_until_complete(async_setup_component(hass, 'frontend', {
|
||||
DOMAIN: {
|
||||
ATTR_EXTRA_HTML_URL: ["https://domain.com/my_extra_url.html"]
|
||||
}}))
|
||||
return hass.loop.run_until_complete(test_client(hass.http.app))
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_frontend_and_static(mock_http_client):
|
||||
"""Test if we can get the frontend."""
|
||||
@@ -143,3 +154,12 @@ def test_missing_themes(mock_http_client):
|
||||
json = yield from resp.json()
|
||||
assert json['default_theme'] == 'default'
|
||||
assert json['themes'] == {}
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_extra_urls(mock_http_client_with_urls):
|
||||
"""Test that extra urls are loaded."""
|
||||
resp = yield from mock_http_client_with_urls.get('/states')
|
||||
assert resp.status == 200
|
||||
text = yield from resp.text()
|
||||
assert text.find('href=\'https://domain.com/my_extra_url.html\'') >= 0
|
||||
|
||||
Reference in New Issue
Block a user