mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Add missing hass type hint in component tests (p) (#124227)
This commit is contained in:
parent
93f791e5d0
commit
d961e20b15
@ -18,7 +18,7 @@ from .conftest import MOCK_CONFIG_DATA, MOCK_DEVICE_INFO, MOCK_ENCRYPTION_DATA
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def setup_panasonic_viera(hass):
|
||||
async def setup_panasonic_viera(hass: HomeAssistant) -> None:
|
||||
"""Initialize integration for tests."""
|
||||
mock_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""The tests for the Pilight sensor platform."""
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
@ -17,7 +18,9 @@ def setup_comp(hass: HomeAssistant) -> None:
|
||||
mock_component(hass, "pilight")
|
||||
|
||||
|
||||
def fire_pilight_message(hass, protocol, data):
|
||||
def fire_pilight_message(
|
||||
hass: HomeAssistant, protocol: str, data: dict[str, Any]
|
||||
) -> None:
|
||||
"""Fire the fake Pilight message."""
|
||||
message = {pilight.CONF_PROTOCOL: protocol}
|
||||
message.update(data)
|
||||
|
@ -5,6 +5,7 @@ from typing import Any
|
||||
|
||||
from plexwebsocket import SIGNAL_CONNECTION_STATE, STATE_CONNECTED
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
@ -39,7 +40,7 @@ def trigger_plex_update(
|
||||
callback(msgtype, UPDATE_PAYLOAD if payload is UNDEFINED else payload, None)
|
||||
|
||||
|
||||
async def wait_for_debouncer(hass):
|
||||
async def wait_for_debouncer(hass: HomeAssistant) -> None:
|
||||
"""Move time forward to wait for sensor debouncer."""
|
||||
next_update = dt_util.utcnow() + timedelta(seconds=3)
|
||||
async_fire_time_changed(hass, next_update)
|
||||
|
@ -10,7 +10,9 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
def init_config_flow(hass, side_effect=None):
|
||||
def init_config_flow(
|
||||
hass: HomeAssistant, side_effect: type[Exception] | None = None
|
||||
) -> config_flow.PointFlowHandler:
|
||||
"""Init a configuration flow."""
|
||||
config_flow.register_flow_implementation(hass, DOMAIN, "id", "secret")
|
||||
flow = config_flow.PointFlowHandler()
|
||||
@ -22,7 +24,7 @@ def init_config_flow(hass, side_effect=None):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def is_authorized():
|
||||
def is_authorized() -> bool:
|
||||
"""Set PointSession authorized."""
|
||||
return True
|
||||
|
||||
|
@ -17,6 +17,7 @@ from tesla_powerwall import (
|
||||
)
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.json import JsonValueType
|
||||
|
||||
from tests.common import load_fixture
|
||||
|
||||
@ -87,7 +88,7 @@ async def _mock_powerwall_return_value(
|
||||
return powerwall_mock
|
||||
|
||||
|
||||
async def _mock_powerwall_site_name(hass, site_name):
|
||||
async def _mock_powerwall_site_name(hass: HomeAssistant, site_name: str) -> MagicMock:
|
||||
powerwall_mock = MagicMock(Powerwall)
|
||||
powerwall_mock.__aenter__.return_value = powerwall_mock
|
||||
|
||||
@ -110,7 +111,7 @@ async def _mock_powerwall_side_effect(site_info=None):
|
||||
return powerwall_mock
|
||||
|
||||
|
||||
async def _async_load_json_fixture(hass, path):
|
||||
async def _async_load_json_fixture(hass: HomeAssistant, path: str) -> JsonValueType:
|
||||
fixture = await hass.async_add_executor_job(
|
||||
load_fixture, os.path.join("powerwall", path)
|
||||
)
|
||||
|
@ -199,7 +199,7 @@ async def test_media_player_is_setup(hass: HomeAssistant) -> None:
|
||||
assert len(hass.data[PS4_DATA].devices) == 1
|
||||
|
||||
|
||||
async def setup_mock_component(hass):
|
||||
async def setup_mock_component(hass: HomeAssistant) -> None:
|
||||
"""Set up Mock Media Player."""
|
||||
entry = MockConfigEntry(domain=ps4.DOMAIN, data=MOCK_DATA, version=VERSION)
|
||||
entry.add_to_manager(hass.config_entries)
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Tests for the PS4 media player platform."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from pyps4_2ndscreen.credential import get_ddp_message
|
||||
@ -130,7 +131,9 @@ MOCK_CONFIG = MockConfigEntry(domain=DOMAIN, data=MOCK_DATA, entry_id=MOCK_ENTRY
|
||||
MOCK_LOAD = "homeassistant.components.ps4.media_player.load_games"
|
||||
|
||||
|
||||
async def setup_mock_component(hass, entry=None):
|
||||
async def setup_mock_component(
|
||||
hass: HomeAssistant, entry: MockConfigEntry | None = None
|
||||
) -> str:
|
||||
"""Set up Mock Media Player."""
|
||||
if entry is None:
|
||||
mock_entry = MockConfigEntry(
|
||||
@ -150,7 +153,9 @@ async def setup_mock_component(hass, entry=None):
|
||||
return mock_entities[0]
|
||||
|
||||
|
||||
async def mock_ddp_response(hass, mock_status_data):
|
||||
async def mock_ddp_response(
|
||||
hass: HomeAssistant, mock_status_data: dict[str, Any]
|
||||
) -> None:
|
||||
"""Mock raw UDP response from device."""
|
||||
mock_protocol = hass.data[PS4_DATA].protocol
|
||||
assert mock_protocol.local_port == DEFAULT_UDP_PORT
|
||||
|
Loading…
x
Reference in New Issue
Block a user