mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Use deprecated_function
This commit is contained in:
parent
7ab62319f9
commit
6ac025c0b3
@ -290,7 +290,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up SimpliSafe as config entry."""
|
||||
_async_standardize_config_entry(hass, entry)
|
||||
|
||||
_verify_domain_control = verify_domain_entity_control(DOMAIN)
|
||||
websession = aiohttp_client.async_get_clientsession(hass)
|
||||
|
||||
try:
|
||||
@ -334,19 +333,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
||||
return wrapper
|
||||
|
||||
@_verify_domain_control
|
||||
@verify_domain_entity_control(DOMAIN)
|
||||
@extract_system
|
||||
async def async_remove_pin(call: ServiceCall, system: SystemType) -> None:
|
||||
"""Remove a PIN."""
|
||||
await system.async_remove_pin(call.data[ATTR_PIN_LABEL_OR_VALUE])
|
||||
|
||||
@_verify_domain_control
|
||||
@verify_domain_entity_control(DOMAIN)
|
||||
@extract_system
|
||||
async def async_set_pin(call: ServiceCall, system: SystemType) -> None:
|
||||
"""Set a PIN."""
|
||||
await system.async_set_pin(call.data[ATTR_PIN_LABEL], call.data[ATTR_PIN_VALUE])
|
||||
|
||||
@_verify_domain_control
|
||||
@verify_domain_entity_control(DOMAIN)
|
||||
@extract_system
|
||||
async def async_set_system_properties(
|
||||
call: ServiceCall, system: SystemType
|
||||
|
@ -63,6 +63,7 @@ from . import (
|
||||
template,
|
||||
translation,
|
||||
)
|
||||
from .deprecation import deprecated_function
|
||||
from .group import expand_entity_ids
|
||||
from .selector import TargetSelector
|
||||
from .typing import ConfigType, TemplateVarsType, VolDictType, VolSchemaType
|
||||
@ -1149,6 +1150,7 @@ def async_register_admin_service(
|
||||
|
||||
@bind_hass
|
||||
@callback
|
||||
@deprecated_function("verify_domain_entity_control", breaks_in_ha_version="2026.7")
|
||||
def verify_domain_control(
|
||||
hass: HomeAssistant, domain: str
|
||||
) -> Callable[[Callable[[ServiceCall], Any]], Callable[[ServiceCall], Any]]:
|
||||
|
@ -1676,7 +1676,9 @@ async def test_register_admin_service_return_response(
|
||||
assert result == {"test-reply": "test-value1"}
|
||||
|
||||
|
||||
async def test_domain_control_not_async(hass: HomeAssistant, mock_entities) -> None:
|
||||
async def test_domain_control_not_async(
|
||||
hass: HomeAssistant, mock_entities, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Test domain verification in a service call with an unknown user."""
|
||||
# Note: deprecated - replaced by test_domain_entity_control_not_async
|
||||
calls = []
|
||||
@ -1688,6 +1690,11 @@ async def test_domain_control_not_async(hass: HomeAssistant, mock_entities) -> N
|
||||
with pytest.raises(exceptions.HomeAssistantError):
|
||||
service.verify_domain_control(hass, "test_domain")(mock_service_log)
|
||||
|
||||
assert (
|
||||
"verify_domain_control is a deprecated function which will be removed in "
|
||||
"HA Core 2026.7. Use verify_domain_entity_control instead"
|
||||
) in caplog.text
|
||||
|
||||
|
||||
async def test_domain_control_unknown(hass: HomeAssistant, mock_entities) -> None:
|
||||
"""Test domain verification in a service call with an unknown user."""
|
||||
@ -1854,7 +1861,7 @@ async def test_domain_entity_control_not_async(
|
||||
calls.append(call)
|
||||
|
||||
with pytest.raises(exceptions.HomeAssistantError):
|
||||
service.verify_domain_entity_control(hass, "test_domain")(mock_service_log)
|
||||
service.verify_domain_entity_control("test_domain")(mock_service_log)
|
||||
|
||||
|
||||
async def test_domain_entity_control_unknown(
|
||||
@ -1871,9 +1878,9 @@ async def test_domain_entity_control_unknown(
|
||||
"homeassistant.helpers.entity_registry.async_get",
|
||||
return_value=Mock(entities=mock_entities),
|
||||
):
|
||||
protected_mock_service = service.verify_domain_entity_control(
|
||||
hass, "test_domain"
|
||||
)(mock_service_log)
|
||||
protected_mock_service = service.verify_domain_entity_control("test_domain")(
|
||||
mock_service_log
|
||||
)
|
||||
|
||||
hass.services.async_register(
|
||||
"test_domain", "test_service", protected_mock_service, schema=None
|
||||
@ -1911,7 +1918,7 @@ async def test_domain_entity_control_unauthorized(
|
||||
"""Define a protected service."""
|
||||
calls.append(call)
|
||||
|
||||
protected_mock_service = service.verify_domain_entity_control(hass, "test_domain")(
|
||||
protected_mock_service = service.verify_domain_entity_control("test_domain")(
|
||||
mock_service_log
|
||||
)
|
||||
|
||||
@ -1952,7 +1959,7 @@ async def test_domain_entity_control_admin(
|
||||
"""Define a protected service."""
|
||||
calls.append(call)
|
||||
|
||||
protected_mock_service = service.verify_domain_entity_control(hass, "test_domain")(
|
||||
protected_mock_service = service.verify_domain_entity_control("test_domain")(
|
||||
mock_service_log
|
||||
)
|
||||
|
||||
@ -1990,7 +1997,7 @@ async def test_domain_entity_control_no_user(hass: HomeAssistant) -> None:
|
||||
"""Define a protected service."""
|
||||
calls.append(call)
|
||||
|
||||
protected_mock_service = service.verify_domain_entity_control(hass, "test_domain")(
|
||||
protected_mock_service = service.verify_domain_entity_control("test_domain")(
|
||||
mock_service_log
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user