Improve typing for calls fixture in tests (a-l) (#118349)

* Improve typing for `calls` fixture in tests (a-l)

* More

* More
This commit is contained in:
epenet
2024-05-29 09:06:48 +02:00
committed by GitHub
parent 89ae425ac2
commit 7e62061b9a
43 changed files with 546 additions and 338 deletions

View File

@@ -9,7 +9,7 @@ import pytest
from homeassistant import setup
from homeassistant.components import automation
from homeassistant.core import HomeAssistant
from homeassistant.core import HomeAssistant, ServiceCall
import homeassistant.util.dt as dt_util
from . import async_init_integration
@@ -31,7 +31,7 @@ ENTITY_OTHER_SWITCH_NUMBER = 2
@pytest.fixture
def calls(hass):
def calls(hass: HomeAssistant) -> list[ServiceCall]:
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation")
@@ -100,7 +100,9 @@ async def setup_automation(hass, trigger):
await hass.async_block_till_done()
async def test_simple(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_simple(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test the simplest form of a LiteJet trigger."""
await setup_automation(
hass, {"platform": "litejet", "number": ENTITY_OTHER_SWITCH_NUMBER}
@@ -113,7 +115,9 @@ async def test_simple(hass: HomeAssistant, calls, mock_litejet) -> None:
assert calls[0].data["id"] == 0
async def test_only_release(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_only_release(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test the simplest form of a LiteJet trigger."""
await setup_automation(
hass, {"platform": "litejet", "number": ENTITY_OTHER_SWITCH_NUMBER}
@@ -124,7 +128,9 @@ async def test_only_release(hass: HomeAssistant, calls, mock_litejet) -> None:
assert len(calls) == 0
async def test_held_more_than_short(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_more_than_short(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test a too short hold."""
await setup_automation(
hass,
@@ -141,7 +147,9 @@ async def test_held_more_than_short(hass: HomeAssistant, calls, mock_litejet) ->
assert len(calls) == 0
async def test_held_more_than_long(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_more_than_long(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test a hold that is long enough."""
await setup_automation(
hass,
@@ -161,7 +169,9 @@ async def test_held_more_than_long(hass: HomeAssistant, calls, mock_litejet) ->
assert len(calls) == 1
async def test_held_less_than_short(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_less_than_short(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test a hold that is short enough."""
await setup_automation(
hass,
@@ -180,7 +190,9 @@ async def test_held_less_than_short(hass: HomeAssistant, calls, mock_litejet) ->
assert calls[0].data["id"] == 0
async def test_held_less_than_long(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_less_than_long(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test a hold that is too long."""
await setup_automation(
hass,
@@ -199,7 +211,9 @@ async def test_held_less_than_long(hass: HomeAssistant, calls, mock_litejet) ->
assert len(calls) == 0
async def test_held_in_range_short(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_in_range_short(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test an in-range trigger with a too short hold."""
await setup_automation(
hass,
@@ -218,7 +232,7 @@ async def test_held_in_range_short(hass: HomeAssistant, calls, mock_litejet) ->
async def test_held_in_range_just_right(
hass: HomeAssistant, calls, mock_litejet
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test an in-range trigger with a just right hold."""
await setup_automation(
@@ -240,7 +254,9 @@ async def test_held_in_range_just_right(
assert calls[0].data["id"] == 0
async def test_held_in_range_long(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_held_in_range_long(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test an in-range trigger with a too long hold."""
await setup_automation(
hass,
@@ -260,7 +276,9 @@ async def test_held_in_range_long(hass: HomeAssistant, calls, mock_litejet) -> N
assert len(calls) == 0
async def test_reload(hass: HomeAssistant, calls, mock_litejet) -> None:
async def test_reload(
hass: HomeAssistant, calls: list[ServiceCall], mock_litejet
) -> None:
"""Test reloading automation."""
await setup_automation(
hass,