Improve hass_ws_client type hint in tests (#89703)
This commit is contained in:
parent
1bc4802c04
commit
71dc98a39c
17 changed files with 52 additions and 71 deletions
|
@ -1,11 +1,9 @@
|
||||||
"""The tests for the automation component."""
|
"""The tests for the automation component."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from unittest.mock import Mock, patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import homeassistant.components.automation as automation
|
import homeassistant.components.automation as automation
|
||||||
|
@ -1437,7 +1435,7 @@ async def test_automation_bad_config_validation(
|
||||||
async def test_automation_with_error_in_script(
|
async def test_automation_with_error_in_script(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test automation with an error in script."""
|
"""Test automation with an error in script."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
"""Tests for the Backup integration."""
|
"""Tests for the Backup integration."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .common import TEST_BACKUP, setup_backup_integration
|
from .common import TEST_BACKUP, setup_backup_integration
|
||||||
|
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_info(
|
async def test_info(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting backup info."""
|
"""Test getting backup info."""
|
||||||
await setup_backup_integration(hass)
|
await setup_backup_integration(hass)
|
||||||
|
@ -34,7 +34,7 @@ async def test_info(
|
||||||
|
|
||||||
async def test_remove(
|
async def test_remove(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removing a backup file."""
|
"""Test removing a backup file."""
|
||||||
|
@ -55,7 +55,7 @@ async def test_remove(
|
||||||
|
|
||||||
async def test_generate(
|
async def test_generate(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test removing a backup file."""
|
"""Test removing a backup file."""
|
||||||
await setup_backup_integration(hass)
|
await setup_backup_integration(hass)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Tests for the devolo Home Control integration."""
|
"""Tests for the devolo Home Control integration."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from devolo_home_control_api.exceptions.gateway import GatewayOfflineError
|
from devolo_home_control_api.exceptions.gateway import GatewayOfflineError
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -16,6 +14,8 @@ from homeassistant.setup import async_setup_component
|
||||||
from . import configure_integration
|
from . import configure_integration
|
||||||
from .mocks import HomeControlMock, HomeControlMockBinarySensor
|
from .mocks import HomeControlMock, HomeControlMockBinarySensor
|
||||||
|
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_entry(hass: HomeAssistant, mock_zeroconf: None) -> None:
|
async def test_setup_entry(hass: HomeAssistant, mock_zeroconf: None) -> None:
|
||||||
"""Test setup entry."""
|
"""Test setup entry."""
|
||||||
|
@ -64,7 +64,7 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
async def test_remove_device(
|
async def test_remove_device(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
):
|
):
|
||||||
"""Test removing a device."""
|
"""Test removing a device."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Switch tests for the D-Link Smart Plug integration."""
|
"""Switch tests for the D-Link Smart Plug integration."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
|
|
||||||
from homeassistant.components.dlink import DOMAIN
|
from homeassistant.components.dlink import DOMAIN
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
|
@ -16,11 +15,12 @@ from homeassistant.setup import async_setup_component
|
||||||
from .conftest import ComponentSetup
|
from .conftest import ComponentSetup
|
||||||
|
|
||||||
from tests.components.repairs import get_repairs
|
from tests.components.repairs import get_repairs
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_switch_state(
|
async def test_switch_state(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[None]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we get the switch status."""
|
"""Test we get the switch status."""
|
||||||
|
|
|
@ -8,7 +8,6 @@ from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from aiohttp.client_exceptions import ClientError
|
from aiohttp.client_exceptions import ClientError
|
||||||
from gcal_sync.auth import API_BASE_URL
|
from gcal_sync.auth import API_BASE_URL
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -32,7 +31,7 @@ from .conftest import (
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator, WebSocketGenerator
|
||||||
|
|
||||||
TEST_ENTITY = TEST_API_ENTITY
|
TEST_ENTITY = TEST_API_ENTITY
|
||||||
TEST_ENTITY_NAME = TEST_API_ENTITY_NAME
|
TEST_ENTITY_NAME = TEST_API_ENTITY_NAME
|
||||||
|
@ -134,7 +133,7 @@ ClientFixture = Callable[[], Awaitable[Client]]
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def ws_client(
|
async def ws_client(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> ClientFixture:
|
) -> ClientFixture:
|
||||||
"""Fixture for creating the test websocket client."""
|
"""Fixture for creating the test websocket client."""
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Test the api module."""
|
"""Test the api module."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import MagicMock, call
|
from unittest.mock import MagicMock, call
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from matter_server.common.errors import InvalidCommand, NodeCommissionFailed
|
from matter_server.common.errors import InvalidCommand, NodeCommissionFailed
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -10,13 +8,14 @@ from homeassistant.components.matter.api import ID, TYPE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
# This tests needs to be adjusted to remove lingering tasks
|
# This tests needs to be adjusted to remove lingering tasks
|
||||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
async def test_commission(
|
async def test_commission(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -58,7 +57,7 @@ async def test_commission(
|
||||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
async def test_commission_on_network(
|
async def test_commission_on_network(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -100,7 +99,7 @@ async def test_commission_on_network(
|
||||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
async def test_set_thread_dataset(
|
async def test_set_thread_dataset(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -142,7 +141,7 @@ async def test_set_thread_dataset(
|
||||||
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
@pytest.mark.parametrize("expected_lingering_tasks", [True])
|
||||||
async def test_set_wifi_credentials(
|
async def test_set_wifi_credentials(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Awaitable, Callable, Generator
|
from collections.abc import Generator
|
||||||
from unittest.mock import AsyncMock, MagicMock, call, patch
|
from unittest.mock import AsyncMock, MagicMock, call, patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
|
from matter_server.client.exceptions import CannotConnect, InvalidServerVersion
|
||||||
from matter_server.client.models.node import MatterNode
|
from matter_server.client.models.node import MatterNode
|
||||||
from matter_server.common.errors import MatterError
|
from matter_server.common.errors import MatterError
|
||||||
|
@ -28,6 +27,7 @@ from homeassistant.setup import async_setup_component
|
||||||
from .common import load_and_parse_node_fixture, setup_integration_with_node_fixture
|
from .common import load_and_parse_node_fixture, setup_integration_with_node_fixture
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="connect_timeout")
|
@pytest.fixture(name="connect_timeout")
|
||||||
|
@ -613,7 +613,7 @@ async def test_remove_entry(
|
||||||
async def test_remove_config_entry_device(
|
async def test_remove_config_entry_device(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that a device can be removed ok."""
|
"""Test that a device can be removed ok."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
@ -656,7 +656,7 @@ async def test_remove_config_entry_device_no_node(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
matter_client: MagicMock,
|
matter_client: MagicMock,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that a device can be removed ok without an existing node."""
|
"""Test that a device can be removed ok without an existing node."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
"""Test function in __init__.py."""
|
"""Test function in __init__.py."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from mysensors import BaseSyncGateway
|
from mysensors import BaseSyncGateway
|
||||||
from mysensors.sensor import Sensor
|
from mysensors.sensor import Sensor
|
||||||
|
|
||||||
|
@ -13,6 +10,7 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def test_remove_config_entry_device(
|
async def test_remove_config_entry_device(
|
||||||
|
@ -20,7 +18,7 @@ async def test_remove_config_entry_device(
|
||||||
gps_sensor: Sensor,
|
gps_sensor: Sensor,
|
||||||
integration: MockConfigEntry,
|
integration: MockConfigEntry,
|
||||||
gateway: BaseSyncGateway,
|
gateway: BaseSyncGateway,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that a device can be removed ok."""
|
"""Test that a device can be removed ok."""
|
||||||
entity_id = "sensor.gps_sensor_1_1"
|
entity_id = "sensor.gps_sensor_1_1"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Tests for 1-Wire config flow."""
|
"""Tests for 1-Wire config flow."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
@ -15,6 +14,8 @@ from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from . import setup_owproxy_mock_devices
|
from . import setup_owproxy_mock_devices
|
||||||
|
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def remove_device(
|
async def remove_device(
|
||||||
ws_client: aiohttp.ClientWebSocketResponse, device_id: str, config_entry_id: str
|
ws_client: aiohttp.ClientWebSocketResponse, device_id: str, config_entry_id: str
|
||||||
|
@ -78,9 +79,7 @@ async def test_registry_cleanup(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
owproxy: MagicMock,
|
owproxy: MagicMock,
|
||||||
hass_ws_client: Callable[
|
hass_ws_client: WebSocketGenerator,
|
||||||
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
|
|
||||||
],
|
|
||||||
):
|
):
|
||||||
"""Test being able to remove a disconnected device."""
|
"""Test being able to remove a disconnected device."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Test pushbullet integration."""
|
"""Test pushbullet integration."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
from pushover_complete import BadAPIRequestError
|
from pushover_complete import BadAPIRequestError
|
||||||
import pytest
|
import pytest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
|
@ -17,6 +15,7 @@ from . import MOCK_CONFIG
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.components.repairs import get_repairs
|
from tests.components.repairs import get_repairs
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=False)
|
@pytest.fixture(autouse=False)
|
||||||
|
@ -30,9 +29,7 @@ def mock_pushover():
|
||||||
|
|
||||||
async def test_setup(
|
async def test_setup(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[
|
hass_ws_client: WebSocketGenerator,
|
||||||
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
|
|
||||||
],
|
|
||||||
mock_pushover: MagicMock,
|
mock_pushover: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test integration failed due to an error."""
|
"""Test integration failed due to an error."""
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
"""Tests for the repairs integration."""
|
"""Tests for the repairs integration."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def get_repairs(
|
async def get_repairs(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
):
|
):
|
||||||
"""Return the repairs list of issues."""
|
"""Return the repairs list of issues."""
|
||||||
assert await async_setup_component(hass, "repairs", {})
|
assert await async_setup_component(hass, "repairs", {})
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Test the repairs websocket API."""
|
"""Test the repairs websocket API."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import AsyncMock, Mock
|
from unittest.mock import AsyncMock, Mock
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -489,7 +487,7 @@ async def test_non_compliant_platform(
|
||||||
@freeze_time("2022-07-21 08:22:00")
|
@freeze_time("2022-07-21 08:22:00")
|
||||||
async def test_sync_methods(
|
async def test_sync_methods(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test sync method for creating and deleting an issue."""
|
"""Test sync method for creating and deleting an issue."""
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
"""Test the repairs websocket API."""
|
"""Test the repairs websocket API."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import ANY, AsyncMock, Mock
|
from unittest.mock import ANY, AsyncMock, Mock
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
import pytest
|
import pytest
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -524,7 +522,7 @@ async def test_list_issues(
|
||||||
async def test_fix_issue_aborted(
|
async def test_fix_issue_aborted(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can fix an issue."""
|
"""Test we can fix an issue."""
|
||||||
assert await async_setup_component(hass, "http", {})
|
assert await async_setup_component(hass, "http", {})
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ from .conftest import SERVER_URL, STREAM_SOURCE, ComponentSetup
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
# The webrtc component does not inspect the details of the offer and answer,
|
# The webrtc component does not inspect the details of the offer and answer,
|
||||||
# and is only a pass through.
|
# and is only a pass through.
|
||||||
|
@ -83,7 +83,7 @@ async def test_setup_communication_failure(
|
||||||
async def test_offer_for_stream_source(
|
async def test_offer_for_stream_source(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
hass_ws_client: Callable[[...], Awaitable[aiohttp.ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
mock_camera: Any,
|
mock_camera: Any,
|
||||||
rtsp_to_webrtc_client: Any,
|
rtsp_to_webrtc_client: Any,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
|
@ -124,7 +124,7 @@ async def test_offer_for_stream_source(
|
||||||
async def test_offer_failure(
|
async def test_offer_failure(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
aioclient_mock: AiohttpClientMocker,
|
||||||
hass_ws_client: Callable[[...], Awaitable[aiohttp.ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
mock_camera: Any,
|
mock_camera: Any,
|
||||||
rtsp_to_webrtc_client: Any,
|
rtsp_to_webrtc_client: Any,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
|
@ -161,7 +161,7 @@ async def test_no_stun_server(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
rtsp_to_webrtc_client: Any,
|
rtsp_to_webrtc_client: Any,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
hass_ws_client: Callable[[...], Awaitable[aiohttp.ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test successful setup and unload."""
|
"""Test successful setup and unload."""
|
||||||
await setup_integration()
|
await setup_integration()
|
||||||
|
@ -188,7 +188,7 @@ async def test_stun_server(
|
||||||
rtsp_to_webrtc_client: Any,
|
rtsp_to_webrtc_client: Any,
|
||||||
setup_integration: ComponentSetup,
|
setup_integration: ComponentSetup,
|
||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
hass_ws_client: Callable[[...], Awaitable[aiohttp.ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test successful setup and unload."""
|
"""Test successful setup and unload."""
|
||||||
await setup_integration()
|
await setup_integration()
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
"""Test for the Schedule integration."""
|
"""Test for the Schedule integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.schedule import STORAGE_VERSION, STORAGE_VERSION_MINOR
|
from homeassistant.components.schedule import STORAGE_VERSION, STORAGE_VERSION_MINOR
|
||||||
|
@ -39,6 +38,7 @@ from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockUser, async_capture_events, async_fire_time_changed
|
from tests.common import MockUser, async_capture_events, async_fire_time_changed
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -537,7 +537,7 @@ async def test_schedule_updates(
|
||||||
|
|
||||||
async def test_ws_list(
|
async def test_ws_list(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test listing via WS."""
|
"""Test listing via WS."""
|
||||||
|
@ -567,7 +567,7 @@ async def test_ws_list(
|
||||||
|
|
||||||
async def test_ws_delete(
|
async def test_ws_delete(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test WS delete cleans up entity registry."""
|
"""Test WS delete cleans up entity registry."""
|
||||||
|
@ -602,7 +602,7 @@ async def test_ws_delete(
|
||||||
)
|
)
|
||||||
async def test_update(
|
async def test_update(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
||||||
to: str,
|
to: str,
|
||||||
next_event: str,
|
next_event: str,
|
||||||
|
@ -672,7 +672,7 @@ async def test_update(
|
||||||
)
|
)
|
||||||
async def test_ws_create(
|
async def test_ws_create(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
schedule_setup: Callable[..., Coroutine[Any, Any, bool]],
|
||||||
freezer,
|
freezer,
|
||||||
to: str,
|
to: str,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
@ -23,6 +22,7 @@ from . import _patch_discovery
|
||||||
from .utils import MockUFPFixture, init_entry, time_changed
|
from .utils import MockUFPFixture, init_entry, time_changed
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
async def remove_device(
|
async def remove_device(
|
||||||
|
@ -217,9 +217,7 @@ async def test_device_remove_devices(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
ufp: MockUFPFixture,
|
ufp: MockUFPFixture,
|
||||||
light: Light,
|
light: Light,
|
||||||
hass_ws_client: Callable[
|
hass_ws_client: WebSocketGenerator,
|
||||||
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
|
|
||||||
],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can only remove a device that no longer exists."""
|
"""Test we can only remove a device that no longer exists."""
|
||||||
|
|
||||||
|
@ -252,9 +250,7 @@ async def test_device_remove_devices(
|
||||||
async def test_device_remove_devices_nvr(
|
async def test_device_remove_devices_nvr(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
ufp: MockUFPFixture,
|
ufp: MockUFPFixture,
|
||||||
hass_ws_client: Callable[
|
hass_ws_client: WebSocketGenerator,
|
||||||
[HomeAssistant], Awaitable[aiohttp.ClientWebSocketResponse]
|
|
||||||
],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can only remove a NVR device that no longer exists."""
|
"""Test we can only remove a NVR device that no longer exists."""
|
||||||
assert await async_setup_component(hass, "config", {})
|
assert await async_setup_component(hass, "config", {})
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""The tests for the Update component."""
|
"""The tests for the Update component."""
|
||||||
from collections.abc import Awaitable, Callable
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from aiohttp import ClientWebSocketResponse
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.update import (
|
from homeassistant.components.update import (
|
||||||
|
@ -40,6 +38,7 @@ from homeassistant.helpers.event import async_track_state_change_event
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import MockEntityPlatform, mock_restore_cache
|
from tests.common import MockEntityPlatform, mock_restore_cache
|
||||||
|
from tests.typing import WebSocketGenerator
|
||||||
|
|
||||||
|
|
||||||
class MockUpdateEntity(UpdateEntity):
|
class MockUpdateEntity(UpdateEntity):
|
||||||
|
@ -681,7 +680,7 @@ async def test_restore_state(
|
||||||
async def test_release_notes(
|
async def test_release_notes(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting the release notes over the websocket connection."""
|
"""Test getting the release notes over the websocket connection."""
|
||||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||||
|
@ -707,7 +706,7 @@ async def test_release_notes(
|
||||||
async def test_release_notes_entity_not_found(
|
async def test_release_notes_entity_not_found(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting the release notes for not found entity."""
|
"""Test getting the release notes for not found entity."""
|
||||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||||
|
@ -734,7 +733,7 @@ async def test_release_notes_entity_not_found(
|
||||||
async def test_release_notes_entity_does_not_support_release_notes(
|
async def test_release_notes_entity_does_not_support_release_notes(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting the release notes for entity that does not support release notes."""
|
"""Test getting the release notes for entity that does not support release notes."""
|
||||||
platform = getattr(hass.components, f"test.{DOMAIN}")
|
platform = getattr(hass.components, f"test.{DOMAIN}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue