mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Add Context to service_calls fixture (#120923)
This commit is contained in:
parent
546d6b22f1
commit
61b2e4ca32
@ -55,6 +55,7 @@ from homeassistant.config import YAML_CONFIG_FILE
|
|||||||
from homeassistant.config_entries import ConfigEntries, ConfigEntry, ConfigEntryState
|
from homeassistant.config_entries import ConfigEntries, ConfigEntry, ConfigEntryState
|
||||||
from homeassistant.const import HASSIO_USER_NAME
|
from homeassistant.const import HASSIO_USER_NAME
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
|
Context,
|
||||||
CoreState,
|
CoreState,
|
||||||
HassJob,
|
HassJob,
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
@ -1661,7 +1662,7 @@ def label_registry(hass: HomeAssistant) -> lr.LabelRegistry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def service_calls(hass: HomeAssistant) -> Generator[None, None, list[ServiceCall]]:
|
def service_calls(hass: HomeAssistant) -> Generator[list[ServiceCall]]:
|
||||||
"""Track all service calls."""
|
"""Track all service calls."""
|
||||||
calls = []
|
calls = []
|
||||||
|
|
||||||
@ -1672,15 +1673,23 @@ def service_calls(hass: HomeAssistant) -> Generator[None, None, list[ServiceCall
|
|||||||
domain: str,
|
domain: str,
|
||||||
service: str,
|
service: str,
|
||||||
service_data: dict[str, Any] | None = None,
|
service_data: dict[str, Any] | None = None,
|
||||||
**kwargs: Any,
|
blocking: bool = False,
|
||||||
|
context: Context | None = None,
|
||||||
|
target: dict[str, Any] | None = None,
|
||||||
|
return_response: bool = False,
|
||||||
) -> ServiceResponse:
|
) -> ServiceResponse:
|
||||||
calls.append(ServiceCall(domain, service, service_data))
|
calls.append(
|
||||||
|
ServiceCall(domain, service, service_data, context, return_response)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
return await _original_async_call(
|
return await _original_async_call(
|
||||||
domain,
|
domain,
|
||||||
service,
|
service,
|
||||||
service_data,
|
service_data,
|
||||||
**kwargs,
|
blocking,
|
||||||
|
context,
|
||||||
|
target,
|
||||||
|
return_response,
|
||||||
)
|
)
|
||||||
except ha.ServiceNotFound:
|
except ha.ServiceNotFound:
|
||||||
_LOGGER.debug("Ignoring unknown service call to %s.%s", domain, service)
|
_LOGGER.debug("Ignoring unknown service call to %s.%s", domain, service)
|
||||||
@ -1697,7 +1706,7 @@ def snapshot(snapshot: SnapshotAssertion) -> SnapshotAssertion:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def disable_block_async_io() -> Generator[Any, Any, None]:
|
def disable_block_async_io() -> Generator[None]:
|
||||||
"""Fixture to disable the loop protection from block_async_io."""
|
"""Fixture to disable the loop protection from block_async_io."""
|
||||||
yield
|
yield
|
||||||
calls = block_async_io._BLOCKED_CALLS.calls
|
calls = block_async_io._BLOCKED_CALLS.calls
|
||||||
|
Loading…
x
Reference in New Issue
Block a user