Resolve and caches paths for CachingStaticResource in the executor (#74474)

This commit is contained in:
J. Nick Koston 2022-07-06 13:49:48 -05:00 committed by GitHub
parent 113ccfe6af
commit 332cf3cd2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 69 additions and 21 deletions

View file

@ -578,3 +578,35 @@ async def test_manifest_json(hass, frontend_themes, mock_http_client):
json = await resp.json()
assert json["theme_color"] != DEFAULT_THEME_COLOR
async def test_static_path_cache(hass, mock_http_client):
"""Test static paths cache."""
resp = await mock_http_client.get("/lovelace/default_view", allow_redirects=False)
assert resp.status == 404
resp = await mock_http_client.get("/frontend_latest/", allow_redirects=False)
assert resp.status == 403
resp = await mock_http_client.get(
"/static/icons/favicon.ico", allow_redirects=False
)
assert resp.status == 200
# and again to make sure the cache works
resp = await mock_http_client.get(
"/static/icons/favicon.ico", allow_redirects=False
)
assert resp.status == 200
resp = await mock_http_client.get(
"/static/fonts/roboto/Roboto-Bold.woff2", allow_redirects=False
)
assert resp.status == 200
resp = await mock_http_client.get("/static/does-not-exist", allow_redirects=False)
assert resp.status == 404
# and again to make sure the cache works
resp = await mock_http_client.get("/static/does-not-exist", allow_redirects=False)
assert resp.status == 404