Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing hass type hint in component tests (p) #124227

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/components/panasonic_viera/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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,
Expand Down
5 changes: 4 additions & 1 deletion tests/components/pilight/test_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The tests for the Pilight sensor platform."""

import logging
from typing import Any

import pytest

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/components/plex/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions tests/components/point/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
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()
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions tests/components/powerwall/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)

from homeassistant.core import HomeAssistant
from homeassistant.util.json import JsonValueType

from tests.common import load_fixture

Expand Down Expand Up @@ -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

Expand All @@ -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)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ps4/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions tests/components/ps4/test_media_player.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -130,7 +131,9 @@
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(
Expand All @@ -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
Expand Down