From 666fc2333a44d72048aaa1a3a514dcdf2cd16ed4 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 3 Jun 2024 10:13:22 +0200 Subject: [PATCH] Add type hints for AiohttpClientMocker in test fixtures (#118691) --- tests/components/hassio/test_addon_panel.py | 2 +- tests/components/hassio/test_binary_sensor.py | 2 +- tests/components/hassio/test_diagnostics.py | 3 ++- tests/components/hassio/test_init.py | 2 +- tests/components/hassio/test_update.py | 2 +- tests/components/hassio/test_websocket_api.py | 2 +- tests/components/onboarding/test_views.py | 13 ++++++++++--- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/components/hassio/test_addon_panel.py b/tests/components/hassio/test_addon_panel.py index 9b1735287c645d..8436b3393b9862 100644 --- a/tests/components/hassio/test_addon_panel.py +++ b/tests/components/hassio/test_addon_panel.py @@ -13,7 +13,7 @@ @pytest.fixture(autouse=True) -def mock_all(aioclient_mock): +def mock_all(aioclient_mock: AiohttpClientMocker) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/hassio/test_binary_sensor.py b/tests/components/hassio/test_binary_sensor.py index bbe498223d1796..af72ea9d702a73 100644 --- a/tests/components/hassio/test_binary_sensor.py +++ b/tests/components/hassio/test_binary_sensor.py @@ -17,7 +17,7 @@ @pytest.fixture(autouse=True) -def mock_all(aioclient_mock, request): +def mock_all(aioclient_mock: AiohttpClientMocker) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/hassio/test_diagnostics.py b/tests/components/hassio/test_diagnostics.py index 83ddd0dbd33937..0d648ba9bdb2c9 100644 --- a/tests/components/hassio/test_diagnostics.py +++ b/tests/components/hassio/test_diagnostics.py @@ -11,13 +11,14 @@ from tests.common import MockConfigEntry from tests.components.diagnostics import get_diagnostics_for_config_entry +from tests.test_util.aiohttp import AiohttpClientMocker from tests.typing import ClientSessionGenerator MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture(autouse=True) -def mock_all(aioclient_mock, request): +def mock_all(aioclient_mock: AiohttpClientMocker) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index d4ec2d0149c563..eddd4e5e04f21a 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -52,7 +52,7 @@ def os_info(extra_os_info): @pytest.fixture(autouse=True) -def mock_all(aioclient_mock, request, os_info): +def mock_all(aioclient_mock: AiohttpClientMocker, os_info) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/hassio/test_update.py b/tests/components/hassio/test_update.py index e79e975a52fd18..9a047010cc3c6d 100644 --- a/tests/components/hassio/test_update.py +++ b/tests/components/hassio/test_update.py @@ -21,7 +21,7 @@ @pytest.fixture(autouse=True) -def mock_all(aioclient_mock, request): +def mock_all(aioclient_mock: AiohttpClientMocker) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/hassio/test_websocket_api.py b/tests/components/hassio/test_websocket_api.py index 67252a0bc8311a..f3be391d9b79f9 100644 --- a/tests/components/hassio/test_websocket_api.py +++ b/tests/components/hassio/test_websocket_api.py @@ -23,7 +23,7 @@ @pytest.fixture(autouse=True) -def mock_all(aioclient_mock): +def mock_all(aioclient_mock: AiohttpClientMocker) -> None: """Mock all setup requests.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.get("http://127.0.0.1/supervisor/ping", json={"result": "ok"}) diff --git a/tests/components/onboarding/test_views.py b/tests/components/onboarding/test_views.py index 45fa654e20f8e5..a0bff5c280c582 100644 --- a/tests/components/onboarding/test_views.py +++ b/tests/components/onboarding/test_views.py @@ -1,6 +1,7 @@ """Test the onboarding views.""" import asyncio +from collections.abc import AsyncGenerator from http import HTTPStatus import os from typing import Any @@ -35,7 +36,9 @@ def auth_active(hass): @pytest.fixture(name="rpi") -async def rpi_fixture(hass, aioclient_mock, mock_supervisor): +async def rpi_fixture( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_supervisor +) -> None: """Mock core info with rpi.""" aioclient_mock.get( "http://127.0.0.1/core/info", @@ -49,7 +52,9 @@ async def rpi_fixture(hass, aioclient_mock, mock_supervisor): @pytest.fixture(name="no_rpi") -async def no_rpi_fixture(hass, aioclient_mock, mock_supervisor): +async def no_rpi_fixture( + hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_supervisor +) -> None: """Mock core info with rpi.""" aioclient_mock.get( "http://127.0.0.1/core/info", @@ -63,7 +68,9 @@ async def no_rpi_fixture(hass, aioclient_mock, mock_supervisor): @pytest.fixture(name="mock_supervisor") -async def mock_supervisor_fixture(hass, aioclient_mock): +async def mock_supervisor_fixture( + aioclient_mock: AiohttpClientMocker, +) -> AsyncGenerator[None, None]: """Mock supervisor.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.post("http://127.0.0.1/supervisor/options", json={"result": "ok"})