Add type hints to integration tests (part 23) (#88235)

This commit is contained in:
epenet 2023-02-17 16:40:46 +01:00 committed by GitHub
parent aa50096a31
commit 9a5f88f55f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 651 additions and 408 deletions

View file

@ -14,6 +14,8 @@ from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.setup import async_setup_component
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
from tests.typing import ClientSessionGenerator
async def setup_component(hass):
@ -43,8 +45,11 @@ async def test_abort_if_no_configuration(hass: HomeAssistant) -> None:
async def test_full_flow_implementation(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test registering an integration and finishing flow works."""
await setup_component(hass)
@ -106,8 +111,11 @@ async def test_full_flow_implementation(
async def test_no_agreements(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test abort when there are no displays."""
await setup_component(hass)
result = await hass.config_entries.flow.async_init(
@ -145,8 +153,11 @@ async def test_no_agreements(
async def test_multiple_agreements(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test abort when there are no displays."""
await setup_component(hass)
result = await hass.config_entries.flow.async_init(
@ -194,8 +205,11 @@ async def test_multiple_agreements(
async def test_agreement_already_set_up(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test showing display form again if display already exists."""
await setup_component(hass)
MockConfigEntry(domain=DOMAIN, unique_id=123).add_to_hass(hass)
@ -234,8 +248,11 @@ async def test_agreement_already_set_up(
async def test_toon_abort(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test we abort on Toon error."""
await setup_component(hass)
result = await hass.config_entries.flow.async_init(
@ -272,7 +289,7 @@ async def test_toon_abort(
assert result2["reason"] == "connection_error"
async def test_import(hass, current_request_with_host):
async def test_import(hass: HomeAssistant, current_request_with_host: None) -> None:
"""Test if importing step works."""
await setup_component(hass)
@ -287,8 +304,11 @@ async def test_import(hass, current_request_with_host):
async def test_import_migration(
hass, hass_client_no_auth, aioclient_mock, current_request_with_host
):
hass: HomeAssistant,
hass_client_no_auth: ClientSessionGenerator,
aioclient_mock: AiohttpClientMocker,
current_request_with_host: None,
) -> None:
"""Test if importing step with migration works."""
old_entry = MockConfigEntry(domain=DOMAIN, unique_id=123, version=1)
old_entry.add_to_hass(hass)