Improve type hints in kitchen_sink tests (#121509)

pull/121516/head^2
epenet 2024-07-08 12:54:43 +02:00 committed by GitHub
parent c4c623ea99
commit 148803460b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 13 deletions

View File

@ -7,7 +7,7 @@ from unittest.mock import ANY
import pytest
from homeassistant.components.kitchen_sink import DOMAIN
from homeassistant.components.recorder import Recorder, get_instance
from homeassistant.components.recorder import get_instance
from homeassistant.components.recorder.statistics import (
async_add_external_statistics,
get_last_statistics,
@ -24,14 +24,13 @@ from tests.typing import ClientSessionGenerator, WebSocketGenerator
@pytest.fixture
def mock_history(hass):
def mock_history(hass: HomeAssistant) -> None:
"""Mock history component loaded."""
hass.config.components.add("history")
async def test_demo_statistics(
recorder_mock: Recorder, mock_history, hass: HomeAssistant
) -> None:
@pytest.mark.usefixtures("recorder_mock", "mock_history")
async def test_demo_statistics(hass: HomeAssistant) -> None:
"""Test that the kitchen sink component makes some statistics available."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done()
@ -63,9 +62,8 @@ async def test_demo_statistics(
} in statistic_ids
async def test_demo_statistics_growth(
recorder_mock: Recorder, mock_history, hass: HomeAssistant
) -> None:
@pytest.mark.usefixtures("recorder_mock", "mock_history")
async def test_demo_statistics_growth(hass: HomeAssistant) -> None:
"""Test that the kitchen sink sum statistics adds to the previous state."""
hass.config.units = US_CUSTOMARY_SYSTEM
@ -104,8 +102,8 @@ async def test_demo_statistics_growth(
@pytest.mark.freeze_time("2023-10-21")
@pytest.mark.usefixtures("mock_history")
async def test_issues_created(
mock_history,
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
hass_ws_client: WebSocketGenerator,

View File

@ -1,5 +1,6 @@
"""The tests for the demo switch component."""
from collections.abc import Generator
from unittest.mock import patch
import pytest
@ -20,7 +21,7 @@ SWITCH_ENTITY_IDS = ["switch.outlet_1", "switch.outlet_2"]
@pytest.fixture
async def switch_only() -> None:
def switch_only() -> Generator[None]:
"""Enable only the switch platform."""
with patch(
"homeassistant.components.kitchen_sink.COMPONENTS_WITH_DEMO_PLATFORM",
@ -30,7 +31,7 @@ async def switch_only() -> None:
@pytest.fixture(autouse=True)
async def setup_comp(hass, switch_only):
async def setup_comp(hass: HomeAssistant, switch_only: None) -> None:
"""Set up demo component."""
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
await hass.async_block_till_done()
@ -55,7 +56,7 @@ async def test_state(
@pytest.mark.parametrize("switch_entity_id", SWITCH_ENTITY_IDS)
async def test_turn_on(hass: HomeAssistant, switch_entity_id) -> None:
async def test_turn_on(hass: HomeAssistant, switch_entity_id: str) -> None:
"""Test switch turn on method."""
await hass.services.async_call(
SWITCH_DOMAIN,
@ -79,7 +80,7 @@ async def test_turn_on(hass: HomeAssistant, switch_entity_id) -> None:
@pytest.mark.parametrize("switch_entity_id", SWITCH_ENTITY_IDS)
async def test_turn_off(hass: HomeAssistant, switch_entity_id) -> None:
async def test_turn_off(hass: HomeAssistant, switch_entity_id: str) -> None:
"""Test switch turn off method."""
await hass.services.async_call(
SWITCH_DOMAIN,