Add type hints to integration tests (part 15) (#88006)

This commit is contained in:
epenet 2023-02-15 10:00:49 +01:00 committed by GitHub
parent 6c23d6abfe
commit 50cbabb2d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 896 additions and 427 deletions

View file

@ -4,12 +4,13 @@ from unittest.mock import patch
import pytest
from homeassistant.components.netatmo import sensor
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .common import TEST_TIME, selected_platforms
async def test_weather_sensor(hass, config_entry, netatmo_auth):
async def test_weather_sensor(hass: HomeAssistant, config_entry, netatmo_auth) -> None:
"""Test weather sensor setup."""
with patch("time.time", return_value=TEST_TIME), selected_platforms(["sensor"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -24,7 +25,9 @@ async def test_weather_sensor(hass, config_entry, netatmo_auth):
assert hass.states.get(f"{prefix}pressure").state == "1014.5"
async def test_public_weather_sensor(hass, config_entry, netatmo_auth):
async def test_public_weather_sensor(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test public weather sensor setup."""
with patch("time.time", return_value=TEST_TIME), selected_platforms(["sensor"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -78,7 +81,7 @@ async def test_public_weather_sensor(hass, config_entry, netatmo_auth):
"strength, expected",
[(50, "Full"), (60, "High"), (80, "Medium"), (90, "Low")],
)
async def test_process_wifi(strength, expected):
async def test_process_wifi(strength, expected) -> None:
"""Test wifi strength translation."""
assert sensor.process_wifi(strength) == expected
@ -87,7 +90,7 @@ async def test_process_wifi(strength, expected):
"strength, expected",
[(50, "Full"), (70, "High"), (80, "Medium"), (90, "Low")],
)
async def test_process_rf(strength, expected):
async def test_process_rf(strength, expected) -> None:
"""Test radio strength translation."""
assert sensor.process_rf(strength) == expected
@ -96,7 +99,7 @@ async def test_process_rf(strength, expected):
"health, expected",
[(4, "Unhealthy"), (3, "Poor"), (2, "Fair"), (1, "Fine"), (0, "Healthy")],
)
async def test_process_health(health, expected):
async def test_process_health(health, expected) -> None:
"""Test health index translation."""
assert sensor.process_health(health) == expected
@ -167,8 +170,8 @@ async def test_process_health(health, expected):
],
)
async def test_weather_sensor_enabling(
hass, config_entry, uid, name, expected, netatmo_auth
):
hass: HomeAssistant, config_entry, uid, name, expected, netatmo_auth
) -> None:
"""Test enabling of by default disabled sensors."""
with patch("time.time", return_value=TEST_TIME), selected_platforms(["sensor"]):
states_before = len(hass.states.async_all())
@ -190,7 +193,9 @@ async def test_weather_sensor_enabling(
assert hass.states.get(f"sensor.{name}").state == expected
async def test_climate_battery_sensor(hass, config_entry, netatmo_auth):
async def test_climate_battery_sensor(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test climate device battery sensor."""
with patch("time.time", return_value=TEST_TIME), selected_platforms(
["sensor", "climate"]