1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Add type hints to integration tests (a) (#87684)

* Add type hints to accuweather tests

* Adjust a** components

* Adjust aiohttp_client

* ClientSessionGenerator/WebSocketGenerator
This commit is contained in:
epenet
2023-02-08 12:16:23 +01:00
committed by GitHub
parent 7665c89b83
commit 2545694d41
79 changed files with 720 additions and 425 deletions

View File

@@ -14,9 +14,12 @@ from homeassistant.components.analytics.const import (
ATTR_USAGE,
)
from homeassistant.const import ATTR_DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.loader import IntegrationNotFound
from homeassistant.setup import async_setup_component
from tests.test_util.aiohttp import AiohttpClientMocker
MOCK_UUID = "abcdefg"
MOCK_VERSION = "1970.1.0"
MOCK_VERSION_DEV = "1970.1.0.dev0"
@@ -38,7 +41,7 @@ async def test_no_send(hass, caplog, aioclient_mock):
assert len(aioclient_mock.mock_calls) == 0
async def test_load_with_supervisor_diagnostics(hass):
async def test_load_with_supervisor_diagnostics(hass: HomeAssistant) -> None:
"""Test loading with a supervisor that has diagnostics enabled."""
analytics = Analytics(hass)
assert not analytics.preferences[ATTR_DIAGNOSTICS]
@@ -53,7 +56,7 @@ async def test_load_with_supervisor_diagnostics(hass):
assert analytics.preferences[ATTR_DIAGNOSTICS]
async def test_load_with_supervisor_without_diagnostics(hass):
async def test_load_with_supervisor_without_diagnostics(hass: HomeAssistant) -> None:
"""Test loading with a supervisor that has not diagnostics enabled."""
analytics = Analytics(hass)
analytics._data.preferences[ATTR_DIAGNOSTICS] = True
@@ -343,7 +346,9 @@ async def test_send_statistics_with_supervisor(hass, caplog, aioclient_mock):
assert "'integrations':" not in caplog.text
async def test_reusing_uuid(hass, aioclient_mock):
async def test_reusing_uuid(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test reusing the stored UUID."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
analytics = Analytics(hass)
@@ -376,7 +381,9 @@ async def test_custom_integrations(hass, aioclient_mock, enable_custom_integrati
assert payload["custom_integrations"][0][ATTR_DOMAIN] == "test_package"
async def test_dev_url(hass, aioclient_mock):
async def test_dev_url(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test sending payload to dev url."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL_DEV, status=200)
analytics = Analytics(hass)
@@ -410,7 +417,9 @@ async def test_dev_url_error(hass, aioclient_mock, caplog):
) in caplog.text
async def test_nightly_endpoint(hass, aioclient_mock):
async def test_nightly_endpoint(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test sending payload to production url when running nightly."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
analytics = Analytics(hass)
@@ -425,7 +434,9 @@ async def test_nightly_endpoint(hass, aioclient_mock):
assert str(payload[1]) == ANALYTICS_ENDPOINT_URL
async def test_send_with_no_energy(hass, aioclient_mock):
async def test_send_with_no_energy(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test send base preferences are defined."""
aioclient_mock.post(ANALYTICS_ENDPOINT_URL, status=200)
analytics = Analytics(hass)