Add missing hass type hint in component tests (h) (#124209)
* Add missing hass type hint in component tests (h) * Fix import
This commit is contained in:
parent
f0af33bd2b
commit
a24fdd1c2b
9 changed files with 38 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Test the Logitech Harmony Hub remote."""
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from aioharmony.const import SendCommandDevice
|
||||
|
||||
|
@ -387,7 +388,9 @@ async def test_sync(
|
|||
mock_write_config.assert_called()
|
||||
|
||||
|
||||
async def _send_commands_and_wait(hass, service_data):
|
||||
async def _send_commands_and_wait(
|
||||
hass: HomeAssistant, service_data: dict[str, Any]
|
||||
) -> None:
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
SERVICE_SEND_COMMAND,
|
||||
|
|
|
@ -91,7 +91,9 @@ async def test_select_option(
|
|||
assert hass.states.is_state(ENTITY_SELECT, "power_off")
|
||||
|
||||
|
||||
async def _select_option_and_wait(hass, entity, option):
|
||||
async def _select_option_and_wait(
|
||||
hass: HomeAssistant, entity: str, option: str
|
||||
) -> None:
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Tests for the Heos Media Player platform."""
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from pyheos import CommandFailedError, const
|
||||
from pyheos.error import HeosError
|
||||
|
@ -58,8 +59,12 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
|||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
async def setup_platform(hass, config_entry, config):
|
||||
|
||||
async def setup_platform(
|
||||
hass: HomeAssistant, config_entry: MockConfigEntry, config: dict[str, Any]
|
||||
) -> None:
|
||||
"""Set up the media player platform for testing."""
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await async_setup_component(hass, DOMAIN, config)
|
||||
|
|
|
@ -13,8 +13,10 @@ from homeassistant.components.heos.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
async def setup_component(hass, config_entry):
|
||||
|
||||
async def setup_component(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
||||
"""Set up the component for testing."""
|
||||
config_entry.add_to_hass(hass)
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
|
|
|
@ -6,6 +6,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_zha_config_flow_setup() -> Generator[None]:
|
||||
|
@ -122,7 +124,7 @@ def set_addon_options_fixture():
|
|||
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||
"""Return the install add-on side effect."""
|
||||
|
||||
async def install_addon(hass, slug):
|
||||
async def install_addon(hass: HomeAssistant, slug: str) -> None:
|
||||
"""Mock install add-on."""
|
||||
addon_store_info.return_value = {
|
||||
"installed": "1.0.0",
|
||||
|
|
|
@ -5,6 +5,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
|
||||
def mock_usb_serial_by_id_fixture() -> Generator[MagicMock]:
|
||||
|
@ -122,7 +124,7 @@ def set_addon_options_fixture():
|
|||
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||
"""Return the install add-on side effect."""
|
||||
|
||||
async def install_addon(hass, slug):
|
||||
async def install_addon(hass: HomeAssistant, slug: str) -> None:
|
||||
"""Mock install add-on."""
|
||||
addon_store_info.return_value = {
|
||||
"installed": "1.0.0",
|
||||
|
|
|
@ -6,6 +6,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_zha_config_flow_setup() -> Generator[None]:
|
||||
|
@ -122,7 +124,7 @@ def set_addon_options_fixture():
|
|||
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||
"""Return the install add-on side effect."""
|
||||
|
||||
async def install_addon(hass, slug):
|
||||
async def install_addon(hass: HomeAssistant, slug: str) -> None:
|
||||
"""Mock install add-on."""
|
||||
addon_store_info.return_value = {
|
||||
"installed": "1.0.0",
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
from http import HTTPStatus
|
||||
import json
|
||||
from typing import Any
|
||||
from unittest.mock import mock_open, patch
|
||||
|
||||
from aiohttp.hdrs import AUTHORIZATION
|
||||
from aiohttp.test_utils import TestClient
|
||||
|
||||
import homeassistant.components.html5.notify as html5
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -69,7 +71,11 @@ REGISTER_URL = "/api/notify.html5"
|
|||
PUBLISH_URL = "/api/notify.html5/callback"
|
||||
|
||||
|
||||
async def mock_client(hass, hass_client, registrations=None):
|
||||
async def mock_client(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
registrations: dict[str, Any] | None = None,
|
||||
) -> TestClient:
|
||||
"""Create a test client for HTML5 views."""
|
||||
if registrations is None:
|
||||
registrations = {}
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||
from http import HTTPStatus
|
||||
from ipaddress import ip_network
|
||||
import logging
|
||||
from typing import Any
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from aiohttp import BasicAuth, web
|
||||
|
@ -476,7 +477,11 @@ async def test_auth_access_signed_path_via_websocket(
|
|||
|
||||
@websocket_api.websocket_command({"type": "diagnostics/list"})
|
||||
@callback
|
||||
def get_signed_path(hass, connection, msg):
|
||||
def get_signed_path(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.ActiveConnection,
|
||||
msg: dict[str, Any],
|
||||
) -> None:
|
||||
connection.send_result(
|
||||
msg["id"], {"path": async_sign_path(hass, "/", timedelta(seconds=5))}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue