Add type hints to integration tests (d-e) (#87699)

This commit is contained in:
epenet 2023-02-08 13:01:44 +01:00 committed by GitHub
parent 5e214f2e43
commit 3052de3e8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 765 additions and 450 deletions

View file

@ -13,6 +13,7 @@ from homeassistant.components.elmax.const import (
DOMAIN,
)
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.core import HomeAssistant
from . import (
MOCK_PANEL_ID,
@ -27,7 +28,7 @@ from tests.common import MockConfigEntry
CONF_POLLING = "polling"
async def test_show_form(hass):
async def test_show_form(hass: HomeAssistant) -> None:
"""Test that the form is served with no input."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -36,7 +37,7 @@ async def test_show_form(hass):
assert result["step_id"] == "user"
async def test_standard_setup(hass):
async def test_standard_setup(hass: HomeAssistant) -> None:
"""Test the standard setup case."""
# Setup once.
show_form_result = await hass.config_entries.flow.async_init(
@ -64,7 +65,7 @@ async def test_standard_setup(hass):
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
async def test_one_config_allowed(hass):
async def test_one_config_allowed(hass: HomeAssistant) -> None:
"""Test that only one Elmax configuration is allowed for each panel."""
MockConfigEntry(
domain=DOMAIN,
@ -99,7 +100,7 @@ async def test_one_config_allowed(hass):
assert result["reason"] == "already_configured"
async def test_invalid_credentials(hass):
async def test_invalid_credentials(hass: HomeAssistant) -> None:
"""Test that invalid credentials throws an error."""
with patch(
"elmax_api.http.Elmax.login",
@ -120,7 +121,7 @@ async def test_invalid_credentials(hass):
assert login_result["errors"] == {"base": "invalid_auth"}
async def test_connection_error(hass):
async def test_connection_error(hass: HomeAssistant) -> None:
"""Test other than invalid credentials throws an error."""
with patch(
"elmax_api.http.Elmax.login",
@ -141,7 +142,7 @@ async def test_connection_error(hass):
assert login_result["errors"] == {"base": "network_error"}
async def test_unhandled_error(hass):
async def test_unhandled_error(hass: HomeAssistant) -> None:
"""Test unhandled exceptions."""
with patch(
"elmax_api.http.Elmax.get_panel_status",
@ -169,7 +170,7 @@ async def test_unhandled_error(hass):
assert result["errors"] == {"base": "unknown"}
async def test_invalid_pin(hass):
async def test_invalid_pin(hass: HomeAssistant) -> None:
"""Test error is thrown when a wrong pin is used to pair a panel."""
# Simulate bad pin response.
with patch(
@ -198,7 +199,7 @@ async def test_invalid_pin(hass):
assert result["errors"] == {"base": "invalid_pin"}
async def test_no_online_panel(hass):
async def test_no_online_panel(hass: HomeAssistant) -> None:
"""Test no-online panel is available."""
# Simulate low-level api returns no panels.
with patch(
@ -220,7 +221,7 @@ async def test_no_online_panel(hass):
assert login_result["errors"] == {"base": "no_panel_online"}
async def test_show_reauth(hass):
async def test_show_reauth(hass: HomeAssistant) -> None:
"""Test that the reauth form shows."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -236,7 +237,7 @@ async def test_show_reauth(hass):
assert result["step_id"] == "reauth_confirm"
async def test_reauth_flow(hass):
async def test_reauth_flow(hass: HomeAssistant) -> None:
"""Test that the reauth flow works."""
MockConfigEntry(
domain=DOMAIN,
@ -278,7 +279,7 @@ async def test_reauth_flow(hass):
assert result["reason"] == "reauth_successful"
async def test_reauth_panel_disappeared(hass):
async def test_reauth_panel_disappeared(hass: HomeAssistant) -> None:
"""Test that the case where panel is no longer associated with the user."""
# Simulate a first setup
MockConfigEntry(
@ -321,7 +322,7 @@ async def test_reauth_panel_disappeared(hass):
assert result["errors"] == {"base": "reauth_panel_disappeared"}
async def test_reauth_invalid_pin(hass):
async def test_reauth_invalid_pin(hass: HomeAssistant) -> None:
"""Test that the case where panel is no longer associated with the user."""
MockConfigEntry(
domain=DOMAIN,
@ -363,7 +364,7 @@ async def test_reauth_invalid_pin(hass):
assert result["errors"] == {"base": "invalid_pin"}
async def test_reauth_bad_login(hass):
async def test_reauth_bad_login(hass: HomeAssistant) -> None:
"""Test bad login attempt at reauth time."""
MockConfigEntry(
domain=DOMAIN,