File tree Expand file tree Collapse file tree 3 files changed +14
-12
lines changed
homeassistant/components/http Expand file tree Collapse file tree 3 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -511,12 +511,14 @@ def register_static_path(
511511 ) -> None :
512512 """Register a folder or file to serve as a static path."""
513513 frame .report_usage (
514- "calls hass.http.register_static_path which is deprecated because "
515- "it does blocking I/O in the event loop, instead "
514+ "calls hass.http.register_static_path which "
515+ "does blocking I/O in the event loop, instead "
516516 "call `await hass.http.async_register_static_paths("
517517 f'[StaticPathConfig("{ url_path } ", "{ path } ", { cache_headers } )])`' ,
518518 exclude_integrations = {"http" },
519- core_behavior = frame .ReportBehavior .LOG ,
519+ core_behavior = frame .ReportBehavior .ERROR ,
520+ core_integration_behavior = frame .ReportBehavior .ERROR ,
521+ custom_integration_behavior = frame .ReportBehavior .ERROR ,
520522 breaks_in_ha_version = "2025.7" ,
521523 )
522524 configs = [StaticPathConfig (url_path , path , cache_headers )]
Original file line number Diff line number Diff line change 1616from aiohttp .test_utils import TestClient
1717import pytest
1818
19+ from homeassistant .components .http import StaticPathConfig
1920from homeassistant .components .http .cors import setup_cors
2021from homeassistant .core import HomeAssistant
2122from homeassistant .helpers .http import KEY_ALLOW_CONFIGURED_CORS , HomeAssistantView
@@ -157,7 +158,9 @@ async def test_cors_on_static_files(
157158 assert await async_setup_component (
158159 hass , "frontend" , {"http" : {"cors_allowed_origins" : ["http://www.example.com" ]}}
159160 )
160- hass .http .register_static_path ("/something" , str (Path (__file__ ).parent ))
161+ await hass .http .async_register_static_paths (
162+ [StaticPathConfig ("/something" , str (Path (__file__ ).parent ))]
163+ )
161164
162165 client = await hass_client ()
163166 resp = await client .options (
Original file line number Diff line number Diff line change @@ -530,17 +530,14 @@ async def test_register_static_paths(
530530 """Test registering a static path with old api."""
531531 assert await async_setup_component (hass , "frontend" , {})
532532 path = str (Path (__file__ ).parent )
533- hass .http .register_static_path ("/something" , path )
534- client = await hass_client ()
535- resp = await client .get ("/something/__init__.py" )
536- assert resp .status == HTTPStatus .OK
537533
538- assert (
534+ match_error = (
539535 "Detected code that calls hass.http.register_static_path "
540- "which is deprecated because it does blocking I/O in the "
541- "event loop, instead call "
536+ "which does blocking I/O in the event loop, instead call "
542537 "`await hass.http.async_register_static_paths"
543- ) in caplog .text
538+ )
539+ with pytest .raises (RuntimeError , match = match_error ):
540+ hass .http .register_static_path ("/something" , path )
544541
545542
546543async def test_ssl_issue_if_no_urls_configured (
You can’t perform that action at this time.
0 commit comments