Add missing hass type hint in component tests (f) (#124076)
parent
a8a7d01a84
commit
24680b731f
|
@ -22,7 +22,7 @@ from tests.common import assert_setup_component
|
|||
|
||||
|
||||
@callback
|
||||
def async_start(hass, entity_id=None):
|
||||
def async_start(hass: HomeAssistant, entity_id: str | None = None) -> None:
|
||||
"""Start a FFmpeg process on entity.
|
||||
|
||||
This is a legacy helper method. Do not use it for new tests.
|
||||
|
@ -32,7 +32,7 @@ def async_start(hass, entity_id=None):
|
|||
|
||||
|
||||
@callback
|
||||
def async_stop(hass, entity_id=None):
|
||||
def async_stop(hass: HomeAssistant, entity_id: str | None = None) -> None:
|
||||
"""Stop a FFmpeg process on entity.
|
||||
|
||||
This is a legacy helper method. Do not use it for new tests.
|
||||
|
@ -42,7 +42,7 @@ def async_stop(hass, entity_id=None):
|
|||
|
||||
|
||||
@callback
|
||||
def async_restart(hass, entity_id=None):
|
||||
def async_restart(hass: HomeAssistant, entity_id: str | None = None) -> None:
|
||||
"""Restart a FFmpeg process on entity.
|
||||
|
||||
This is a legacy helper method. Do not use it for new tests.
|
||||
|
|
|
@ -6,6 +6,7 @@ from pyflick.authentication import AuthException
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.flick_electric.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigFlowResult
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
@ -15,7 +16,7 @@ from tests.common import MockConfigEntry
|
|||
CONF = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"}
|
||||
|
||||
|
||||
async def _flow_submit(hass):
|
||||
async def _flow_submit(hass: HomeAssistant) -> ConfigFlowResult:
|
||||
return await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
from datetime import timedelta
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
|
||||
from homeassistant.components.fronius.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST
|
||||
|
@ -114,7 +117,12 @@ def mock_responses(
|
|||
)
|
||||
|
||||
|
||||
async def enable_all_entities(hass, freezer, config_entry_id, time_till_next_update):
|
||||
async def enable_all_entities(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
config_entry_id: str,
|
||||
time_till_next_update: timedelta,
|
||||
) -> None:
|
||||
"""Enable all entities for a config entry and fast forward time to receive data."""
|
||||
registry = er.async_get(hass)
|
||||
entities = er.async_entries_for_config_entry(registry, config_entry_id)
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import MagicMock
|
|||
from homeassistant.components import number
|
||||
from homeassistant.components.fully_kiosk.const import DOMAIN, UPDATE_INTERVAL
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, ServiceResponse
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
@ -81,9 +81,11 @@ async def test_numbers(
|
|||
assert device_entry.sw_version == "1.42.5"
|
||||
|
||||
|
||||
def set_value(hass, entity_id, value):
|
||||
async def set_value(
|
||||
hass: HomeAssistant, entity_id: str, value: float
|
||||
) -> ServiceResponse:
|
||||
"""Set the value of a number entity."""
|
||||
return hass.services.async_call(
|
||||
return await hass.services.async_call(
|
||||
number.DOMAIN,
|
||||
"set_value",
|
||||
{ATTR_ENTITY_ID: entity_id, number.ATTR_VALUE: value},
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import MagicMock
|
|||
from homeassistant.components import switch
|
||||
from homeassistant.components.fully_kiosk.const import DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, ServiceResponse
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_mqtt_message
|
||||
|
@ -149,8 +149,10 @@ def has_subscribed(mqtt_mock: MqttMockHAClient, topic: str) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def call_service(hass, service, entity_id):
|
||||
async def call_service(
|
||||
hass: HomeAssistant, service: str, entity_id: str
|
||||
) -> ServiceResponse:
|
||||
"""Call any service on entity."""
|
||||
return hass.services.async_call(
|
||||
return await hass.services.async_call(
|
||||
switch.DOMAIN, service, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue