mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
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
@ -1,6 +1,7 @@
|
|||||||
"""Test the Logitech Harmony Hub remote."""
|
"""Test the Logitech Harmony Hub remote."""
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from aioharmony.const import SendCommandDevice
|
from aioharmony.const import SendCommandDevice
|
||||||
|
|
||||||
@ -387,7 +388,9 @@ async def test_sync(
|
|||||||
mock_write_config.assert_called()
|
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(
|
await hass.services.async_call(
|
||||||
REMOTE_DOMAIN,
|
REMOTE_DOMAIN,
|
||||||
SERVICE_SEND_COMMAND,
|
SERVICE_SEND_COMMAND,
|
||||||
|
@ -91,7 +91,9 @@ async def test_select_option(
|
|||||||
assert hass.states.is_state(ENTITY_SELECT, "power_off")
|
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(
|
await hass.services.async_call(
|
||||||
SELECT_DOMAIN,
|
SELECT_DOMAIN,
|
||||||
SERVICE_SELECT_OPTION,
|
SERVICE_SELECT_OPTION,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Tests for the Heos Media Player platform."""
|
"""Tests for the Heos Media Player platform."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pyheos import CommandFailedError, const
|
from pyheos import CommandFailedError, const
|
||||||
from pyheos.error import HeosError
|
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.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.setup import async_setup_component
|
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."""
|
"""Set up the media player platform for testing."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
assert await async_setup_component(hass, DOMAIN, config)
|
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.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
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."""
|
"""Set up the component for testing."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
assert await async_setup_component(hass, DOMAIN, {})
|
assert await async_setup_component(hass, DOMAIN, {})
|
||||||
|
@ -6,6 +6,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_zha_config_flow_setup() -> Generator[None]:
|
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):
|
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||||
"""Return the install add-on side effect."""
|
"""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."""
|
"""Mock install add-on."""
|
||||||
addon_store_info.return_value = {
|
addon_store_info.return_value = {
|
||||||
"installed": "1.0.0",
|
"installed": "1.0.0",
|
||||||
|
@ -5,6 +5,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
|
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
|
||||||
def mock_usb_serial_by_id_fixture() -> Generator[MagicMock]:
|
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):
|
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||||
"""Return the install add-on side effect."""
|
"""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."""
|
"""Mock install add-on."""
|
||||||
addon_store_info.return_value = {
|
addon_store_info.return_value = {
|
||||||
"installed": "1.0.0",
|
"installed": "1.0.0",
|
||||||
|
@ -6,6 +6,8 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_zha_config_flow_setup() -> Generator[None]:
|
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):
|
def install_addon_side_effect_fixture(addon_store_info, addon_info):
|
||||||
"""Return the install add-on side effect."""
|
"""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."""
|
"""Mock install add-on."""
|
||||||
addon_store_info.return_value = {
|
addon_store_info.return_value = {
|
||||||
"installed": "1.0.0",
|
"installed": "1.0.0",
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import json
|
import json
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import mock_open, patch
|
from unittest.mock import mock_open, patch
|
||||||
|
|
||||||
from aiohttp.hdrs import AUTHORIZATION
|
from aiohttp.hdrs import AUTHORIZATION
|
||||||
|
from aiohttp.test_utils import TestClient
|
||||||
|
|
||||||
import homeassistant.components.html5.notify as html5
|
import homeassistant.components.html5.notify as html5
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -69,7 +71,11 @@ REGISTER_URL = "/api/notify.html5"
|
|||||||
PUBLISH_URL = "/api/notify.html5/callback"
|
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."""
|
"""Create a test client for HTML5 views."""
|
||||||
if registrations is None:
|
if registrations is None:
|
||||||
registrations = {}
|
registrations = {}
|
||||||
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from aiohttp import BasicAuth, web
|
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"})
|
@websocket_api.websocket_command({"type": "diagnostics/list"})
|
||||||
@callback
|
@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(
|
connection.send_result(
|
||||||
msg["id"], {"path": async_sign_path(hass, "/", timedelta(seconds=5))}
|
msg["id"], {"path": async_sign_path(hass, "/", timedelta(seconds=5))}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user