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

@ -1,6 +1,8 @@
"""The tests for the Netatmo climate platform."""
from unittest.mock import patch
import pytest
from homeassistant.components.climate import (
ATTR_HVAC_MODE,
ATTR_PRESET_MODE,
@ -20,11 +22,14 @@ from homeassistant.components.netatmo.const import (
SERVICE_SET_SCHEDULE,
)
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, CONF_WEBHOOK_ID
from homeassistant.core import HomeAssistant
from .common import selected_platforms, simulate_webhook
async def test_webhook_event_handling_thermostats(hass, config_entry, netatmo_auth):
async def test_webhook_event_handling_thermostats(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service and webhook event handling with thermostats."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -197,8 +202,8 @@ async def test_webhook_event_handling_thermostats(hass, config_entry, netatmo_au
async def test_service_preset_mode_frost_guard_thermostat(
hass, config_entry, netatmo_auth
):
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service with frost guard preset for thermostats."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -269,7 +274,9 @@ async def test_service_preset_mode_frost_guard_thermostat(
)
async def test_service_preset_modes_thermostat(hass, config_entry, netatmo_auth):
async def test_service_preset_modes_thermostat(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service with preset modes for thermostats."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -347,7 +354,9 @@ async def test_service_preset_modes_thermostat(hass, config_entry, netatmo_auth)
assert hass.states.get(climate_entity_livingroom).attributes["temperature"] == 30
async def test_webhook_event_handling_no_data(hass, config_entry, netatmo_auth):
async def test_webhook_event_handling_no_data(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service and webhook event handling with erroneous data."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -396,7 +405,9 @@ async def test_webhook_event_handling_no_data(hass, config_entry, netatmo_auth):
await simulate_webhook(hass, webhook_id, response)
async def test_service_schedule_thermostats(hass, config_entry, caplog, netatmo_auth):
async def test_service_schedule_thermostats(
hass: HomeAssistant, config_entry, caplog: pytest.LogCaptureFixture, netatmo_auth
) -> None:
"""Test service for selecting Netatmo schedule with thermostats."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -448,8 +459,8 @@ async def test_service_schedule_thermostats(hass, config_entry, caplog, netatmo_
async def test_service_preset_mode_already_boost_valves(
hass, config_entry, netatmo_auth
):
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service with boost preset for valves when already in boost mode."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -527,7 +538,9 @@ async def test_service_preset_mode_already_boost_valves(
assert hass.states.get(climate_entity_entrada).attributes["temperature"] == 30
async def test_service_preset_mode_boost_valves(hass, config_entry, netatmo_auth):
async def test_service_preset_mode_boost_valves(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service with boost preset for valves."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -577,7 +590,9 @@ async def test_service_preset_mode_boost_valves(hass, config_entry, netatmo_auth
assert hass.states.get(climate_entity_entrada).attributes["temperature"] == 30
async def test_service_preset_mode_invalid(hass, config_entry, caplog, netatmo_auth):
async def test_service_preset_mode_invalid(
hass: HomeAssistant, config_entry, caplog: pytest.LogCaptureFixture, netatmo_auth
) -> None:
"""Test service with invalid preset."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -595,7 +610,9 @@ async def test_service_preset_mode_invalid(hass, config_entry, caplog, netatmo_a
assert "Preset mode 'invalid' not available" in caplog.text
async def test_valves_service_turn_off(hass, config_entry, netatmo_auth):
async def test_valves_service_turn_off(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service turn off for valves."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -645,7 +662,9 @@ async def test_valves_service_turn_off(hass, config_entry, netatmo_auth):
assert hass.states.get(climate_entity_entrada).state == "off"
async def test_valves_service_turn_on(hass, config_entry, netatmo_auth):
async def test_valves_service_turn_on(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service turn on for valves."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -690,7 +709,9 @@ async def test_valves_service_turn_on(hass, config_entry, netatmo_auth):
assert hass.states.get(climate_entity_entrada).state == "auto"
async def test_webhook_home_id_mismatch(hass, config_entry, netatmo_auth):
async def test_webhook_home_id_mismatch(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service turn on for valves."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)
@ -728,7 +749,9 @@ async def test_webhook_home_id_mismatch(hass, config_entry, netatmo_auth):
assert hass.states.get(climate_entity_entrada).state == "auto"
async def test_webhook_set_point(hass, config_entry, netatmo_auth):
async def test_webhook_set_point(
hass: HomeAssistant, config_entry, netatmo_auth
) -> None:
"""Test service turn on for valves."""
with selected_platforms(["climate"]):
assert await hass.config_entries.async_setup(config_entry.entry_id)