mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Remove deprecated register_static_path
method (#148303)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
parent
799dc97d4a
commit
c296e1f818
@ -37,12 +37,7 @@ from homeassistant.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import config_validation as cv, issue_registry as ir, storage
|
||||||
config_validation as cv,
|
|
||||||
frame,
|
|
||||||
issue_registry as ir,
|
|
||||||
storage,
|
|
||||||
)
|
|
||||||
from homeassistant.helpers.http import (
|
from homeassistant.helpers.http import (
|
||||||
KEY_ALLOW_CONFIGURED_CORS,
|
KEY_ALLOW_CONFIGURED_CORS,
|
||||||
KEY_AUTHENTICATED, # noqa: F401
|
KEY_AUTHENTICATED, # noqa: F401
|
||||||
@ -505,25 +500,6 @@ class HomeAssistantHTTP:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def register_static_path(
|
|
||||||
self, url_path: str, path: str, cache_headers: bool = True
|
|
||||||
) -> None:
|
|
||||||
"""Register a folder or file to serve as a static path."""
|
|
||||||
frame.report_usage(
|
|
||||||
"calls hass.http.register_static_path which "
|
|
||||||
"does blocking I/O in the event loop, instead "
|
|
||||||
"call `await hass.http.async_register_static_paths("
|
|
||||||
f'[StaticPathConfig("{url_path}", "{path}", {cache_headers})])`',
|
|
||||||
exclude_integrations={"http"},
|
|
||||||
core_behavior=frame.ReportBehavior.ERROR,
|
|
||||||
core_integration_behavior=frame.ReportBehavior.ERROR,
|
|
||||||
custom_integration_behavior=frame.ReportBehavior.ERROR,
|
|
||||||
breaks_in_ha_version="2025.7",
|
|
||||||
)
|
|
||||||
configs = [StaticPathConfig(url_path, path, cache_headers)]
|
|
||||||
resources = self._make_static_resources(configs)
|
|
||||||
self._async_register_static_paths(configs, resources)
|
|
||||||
|
|
||||||
def _create_ssl_context(self) -> ssl.SSLContext | None:
|
def _create_ssl_context(self) -> ssl.SSLContext | None:
|
||||||
context: ssl.SSLContext | None = None
|
context: ssl.SSLContext | None = None
|
||||||
assert self.ssl_certificate is not None
|
assert self.ssl_certificate is not None
|
||||||
|
@ -522,24 +522,6 @@ async def test_logging(
|
|||||||
assert "GET /api/states/logging.entity" not in caplog.text
|
assert "GET /api/states/logging.entity" not in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_register_static_paths(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
hass_client: ClientSessionGenerator,
|
|
||||||
caplog: pytest.LogCaptureFixture,
|
|
||||||
) -> None:
|
|
||||||
"""Test registering a static path with old api."""
|
|
||||||
assert await async_setup_component(hass, "frontend", {})
|
|
||||||
path = str(Path(__file__).parent)
|
|
||||||
|
|
||||||
match_error = (
|
|
||||||
"Detected code that calls hass.http.register_static_path "
|
|
||||||
"which does blocking I/O in the event loop, instead call "
|
|
||||||
"`await hass.http.async_register_static_paths"
|
|
||||||
)
|
|
||||||
with pytest.raises(RuntimeError, match=match_error):
|
|
||||||
hass.http.register_static_path("/something", path)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_ssl_issue_if_no_urls_configured(
|
async def test_ssl_issue_if_no_urls_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user