mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Add type hints for AiohttpClientMocker in test fixtures (#118691)
This commit is contained in:
parent
c93d42d59b
commit
666fc2333a
@ -13,7 +13,7 @@ from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
@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"})
|
||||
|
@ -17,7 +17,7 @@ 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"})
|
||||
|
@ -11,13 +11,14 @@ from homeassistant.setup import async_setup_component
|
||||
|
||||
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"})
|
||||
|
@ -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"})
|
||||
|
@ -21,7 +21,7 @@ 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"})
|
||||
|
@ -23,7 +23,7 @@ from tests.typing import WebSocketGenerator
|
||||
|
||||
|
||||
@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"})
|
||||
|
@ -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"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user