mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Import Generator from typing_extensions (5) (#118993)
This commit is contained in:
parent
632238a7f9
commit
59e178df3b
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from tailscale.models import Devices
|
from tailscale.models import Devices
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tailscale.const import CONF_TAILNET, DOMAIN
|
from homeassistant.components.tailscale.const import CONF_TAILNET, DOMAIN
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
@ -27,7 +27,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tailscale.async_setup_entry", return_value=True
|
"homeassistant.components.tailscale.async_setup_entry", return_value=True
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
from gotailwind import TailwindDeviceStatus
|
from gotailwind import TailwindDeviceStatus
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tailwind.const import DOMAIN
|
from homeassistant.components.tailwind.const import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||||
@ -36,7 +36,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tailwind.async_setup_entry", return_value=True
|
"homeassistant.components.tailwind.async_setup_entry", return_value=True
|
||||||
@ -45,7 +45,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_tailwind(device_fixture: str) -> Generator[MagicMock, None, None]:
|
def mock_tailwind(device_fixture: str) -> Generator[MagicMock]:
|
||||||
"""Return a mocked Tailwind client."""
|
"""Return a mocked Tailwind client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""Common fixutres with default mocks as well as common test helper methods."""
|
"""Common fixutres with default mocks as well as common test helper methods."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from Tami4EdgeAPI.device import Device
|
from Tami4EdgeAPI.device import Device
|
||||||
from Tami4EdgeAPI.water_quality import UV, Filter, WaterQuality
|
from Tami4EdgeAPI.water_quality import UV, Filter, WaterQuality
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tami4.const import CONF_REFRESH_TOKEN, DOMAIN
|
from homeassistant.components.tami4.const import CONF_REFRESH_TOKEN, DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -37,7 +37,7 @@ def mock_api(mock__get_devices, mock_get_water_quality):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock__get_devices(request: pytest.FixtureRequest) -> Generator[None, None, None]:
|
def mock__get_devices(request: pytest.FixtureRequest) -> Generator[None]:
|
||||||
"""Fixture to mock _get_devices which makes a call to the API."""
|
"""Fixture to mock _get_devices which makes a call to the API."""
|
||||||
|
|
||||||
side_effect = getattr(request, "param", None)
|
side_effect = getattr(request, "param", None)
|
||||||
@ -62,7 +62,7 @@ def mock__get_devices(request: pytest.FixtureRequest) -> Generator[None, None, N
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_get_water_quality(
|
def mock_get_water_quality(
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
) -> Generator[None, None, None]:
|
) -> Generator[None]:
|
||||||
"""Fixture to mock get_water_quality which makes a call to the API."""
|
"""Fixture to mock get_water_quality which makes a call to the API."""
|
||||||
|
|
||||||
side_effect = getattr(request, "param", None)
|
side_effect = getattr(request, "param", None)
|
||||||
@ -90,7 +90,7 @@ def mock_get_water_quality(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
@ -102,7 +102,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_request_otp(
|
def mock_request_otp(
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
) -> Generator[MagicMock, None, None]:
|
) -> Generator[MagicMock]:
|
||||||
"""Mock request_otp."""
|
"""Mock request_otp."""
|
||||||
|
|
||||||
side_effect = getattr(request, "param", None)
|
side_effect = getattr(request, "param", None)
|
||||||
@ -116,7 +116,7 @@ def mock_request_otp(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_submit_otp(request: pytest.FixtureRequest) -> Generator[MagicMock, None, None]:
|
def mock_submit_otp(request: pytest.FixtureRequest) -> Generator[MagicMock]:
|
||||||
"""Mock submit_otp."""
|
"""Mock submit_otp."""
|
||||||
|
|
||||||
side_effect = getattr(request, "param", None)
|
side_effect = getattr(request, "param", None)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Fixtures for Tankerkoenig integration tests."""
|
"""Fixtures for Tankerkoenig integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tankerkoenig import DOMAIN
|
from homeassistant.components.tankerkoenig import DOMAIN
|
||||||
from homeassistant.const import CONF_SHOW_ON_MAP
|
from homeassistant.const import CONF_SHOW_ON_MAP
|
||||||
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="tankerkoenig")
|
@pytest.fixture(name="tankerkoenig")
|
||||||
def mock_tankerkoenig() -> Generator[AsyncMock, None, None]:
|
def mock_tankerkoenig() -> Generator[AsyncMock]:
|
||||||
"""Mock the aiotankerkoenig client."""
|
"""Mock the aiotankerkoenig client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Fixtures for TechnoVE integration tests."""
|
"""Fixtures for TechnoVE integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from technove import Station as TechnoVEStation
|
from technove import Station as TechnoVEStation
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.technove.const import DOMAIN
|
from homeassistant.components.technove.const import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
@ -24,7 +24,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.technove.async_setup_entry", return_value=True
|
"homeassistant.components.technove.async_setup_entry", return_value=True
|
||||||
@ -33,7 +33,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_onboarding() -> Generator[MagicMock, None, None]:
|
def mock_onboarding() -> Generator[MagicMock]:
|
||||||
"""Mock that Home Assistant is currently onboarding."""
|
"""Mock that Home Assistant is currently onboarding."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.onboarding.async_is_onboarded",
|
"homeassistant.components.onboarding.async_is_onboarded",
|
||||||
@ -49,7 +49,7 @@ def device_fixture() -> TechnoVEStation:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_technove(device_fixture: TechnoVEStation) -> Generator[MagicMock, None, None]:
|
def mock_technove(device_fixture: TechnoVEStation) -> Generator[MagicMock]:
|
||||||
"""Return a mocked TechnoVE client."""
|
"""Return a mocked TechnoVE client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import json
|
import json
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
from pytedee_async.bridge import TedeeBridge
|
from pytedee_async.bridge import TedeeBridge
|
||||||
from pytedee_async.lock import TedeeLock
|
from pytedee_async.lock import TedeeLock
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
|
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_WEBHOOK_ID
|
from homeassistant.const import CONF_HOST, CONF_WEBHOOK_ID
|
||||||
@ -37,7 +37,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tedee.async_setup_entry", return_value=True
|
"homeassistant.components.tedee.async_setup_entry", return_value=True
|
||||||
@ -46,7 +46,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_tedee() -> Generator[MagicMock, None, None]:
|
def mock_tedee() -> Generator[MagicMock]:
|
||||||
"""Return a mocked Tedee client."""
|
"""Return a mocked Tedee client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Fixtures for Time & Date integration tests."""
|
"""Fixtures for Time & Date integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.time_date.async_setup_entry", return_value=True
|
"homeassistant.components.time_date.async_setup_entry", return_value=True
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""Tests for the todo integration."""
|
"""Tests for the todo integration."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
import zoneinfo
|
import zoneinfo
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.todo import (
|
from homeassistant.components.todo import (
|
||||||
@ -75,7 +75,7 @@ class MockTodoListEntity(TodoListEntity):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""Common fixtures for the todoist tests."""
|
"""Common fixtures for the todoist tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
@ -8,6 +7,7 @@ import pytest
|
|||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
from requests.models import Response
|
from requests.models import Response
|
||||||
from todoist_api_python.models import Collaborator, Due, Label, Project, Task
|
from todoist_api_python.models import Collaborator, Due, Label, Project, Task
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.todoist import DOMAIN
|
from homeassistant.components.todoist import DOMAIN
|
||||||
from homeassistant.const import CONF_TOKEN, Platform
|
from homeassistant.const import CONF_TOKEN, Platform
|
||||||
@ -24,7 +24,7 @@ TODAY = dt_util.now().strftime("%Y-%m-%d")
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.todoist.async_setup_entry", return_value=True
|
"homeassistant.components.todoist.async_setup_entry", return_value=True
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""tplink conftest."""
|
"""tplink conftest."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import copy
|
import copy
|
||||||
from unittest.mock import DEFAULT, AsyncMock, patch
|
from unittest.mock import DEFAULT, AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tplink import DOMAIN
|
from homeassistant.components.tplink import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -85,7 +85,7 @@ def entity_reg_fixture(hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch.multiple(
|
with patch.multiple(
|
||||||
async_setup=DEFAULT,
|
async_setup=DEFAULT,
|
||||||
@ -97,7 +97,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_init() -> Generator[AsyncMock, None, None]:
|
def mock_init() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch.multiple(
|
with patch.multiple(
|
||||||
"homeassistant.components.tplink",
|
"homeassistant.components.tplink",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"""Test fixtures for TP-Link Omada integration."""
|
"""Test fixtures for TP-Link Omada integration."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import json
|
import json
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
@ -11,6 +10,7 @@ from tplink_omada_client.devices import (
|
|||||||
OmadaSwitch,
|
OmadaSwitch,
|
||||||
OmadaSwitchPortDetails,
|
OmadaSwitchPortDetails,
|
||||||
)
|
)
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tplink_omada.config_flow import CONF_SITE
|
from homeassistant.components.tplink_omada.config_flow import CONF_SITE
|
||||||
from homeassistant.components.tplink_omada.const import DOMAIN
|
from homeassistant.components.tplink_omada.const import DOMAIN
|
||||||
@ -38,7 +38,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tplink_omada.async_setup_entry", return_value=True
|
"homeassistant.components.tplink_omada.async_setup_entry", return_value=True
|
||||||
@ -47,7 +47,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_omada_site_client() -> Generator[AsyncMock, None, None]:
|
def mock_omada_site_client() -> Generator[AsyncMock]:
|
||||||
"""Mock Omada site client."""
|
"""Mock Omada site client."""
|
||||||
site_client = AsyncMock()
|
site_client = AsyncMock()
|
||||||
|
|
||||||
@ -73,9 +73,7 @@ def mock_omada_site_client() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_omada_client(
|
def mock_omada_client(mock_omada_site_client: AsyncMock) -> Generator[MagicMock]:
|
||||||
mock_omada_site_client: AsyncMock,
|
|
||||||
) -> Generator[MagicMock, None, None]:
|
|
||||||
"""Mock Omada client."""
|
"""Mock Omada client."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tplink_omada.create_omada_client",
|
"homeassistant.components.tplink_omada.create_omada_client",
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Common fixtures for the Traccar Server tests."""
|
"""Common fixtures for the Traccar Server tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytraccar import ApiClient, SubscriptionStatus
|
from pytraccar import ApiClient, SubscriptionStatus
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.traccar_server.const import (
|
from homeassistant.components.traccar_server.const import (
|
||||||
CONF_CUSTOM_ATTRIBUTES,
|
CONF_CUSTOM_ATTRIBUTES,
|
||||||
@ -30,7 +30,7 @@ from tests.common import (
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_traccar_api_client() -> Generator[AsyncMock, None, None]:
|
def mock_traccar_api_client() -> Generator[AsyncMock]:
|
||||||
"""Mock a Traccar ApiClient client."""
|
"""Mock a Traccar ApiClient client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Test the Traccar Server config flow."""
|
"""Test the Traccar Server config flow."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytraccar import TraccarException
|
from pytraccar import TraccarException
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.traccar.device_tracker import PLATFORM_SCHEMA
|
from homeassistant.components.traccar.device_tracker import PLATFORM_SCHEMA
|
||||||
@ -34,7 +34,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
async def test_form(
|
async def test_form(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -77,7 +77,7 @@ async def test_form_cannot_connect(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
side_effect: Exception,
|
side_effect: Exception,
|
||||||
error: str,
|
error: str,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we handle cannot connect error."""
|
"""Test we handle cannot connect error."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -127,7 +127,7 @@ async def test_form_cannot_connect(
|
|||||||
async def test_options(
|
async def test_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test options flow."""
|
"""Test options flow."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
@ -231,7 +231,7 @@ async def test_import_from_yaml(
|
|||||||
imported: dict[str, Any],
|
imported: dict[str, Any],
|
||||||
data: dict[str, Any],
|
data: dict[str, Any],
|
||||||
options: dict[str, Any],
|
options: dict[str, Any],
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test importing configuration from YAML."""
|
"""Test importing configuration from YAML."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -277,7 +277,7 @@ async def test_abort_import_already_configured(hass: HomeAssistant) -> None:
|
|||||||
async def test_abort_already_configured(
|
async def test_abort_already_configured(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test abort for existing server."""
|
"""Test abort for existing server."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Test Traccar Server diagnostics."""
|
"""Test Traccar Server diagnostics."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
@ -21,7 +21,7 @@ from tests.typing import ClientSessionGenerator
|
|||||||
async def test_entry_diagnostics(
|
async def test_entry_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -44,7 +44,7 @@ async def test_entry_diagnostics(
|
|||||||
async def test_device_diagnostics(
|
async def test_device_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
@ -86,7 +86,7 @@ async def test_device_diagnostics(
|
|||||||
async def test_device_diagnostics_with_disabled_entity(
|
async def test_device_diagnostics_with_disabled_entity(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_traccar_api_client: Generator[AsyncMock, None, None],
|
mock_traccar_api_client: Generator[AsyncMock],
|
||||||
mock_config_entry: MockConfigEntry,
|
mock_config_entry: MockConfigEntry,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""Common fixtures for the Tractive tests."""
|
"""Common fixtures for the Tractive tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from aiotractive.trackable_object import TrackableObject
|
from aiotractive.trackable_object import TrackableObject
|
||||||
from aiotractive.tracker import Tracker
|
from aiotractive.tracker import Tracker
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tractive.const import DOMAIN, SERVER_UNAVAILABLE
|
from homeassistant.components.tractive.const import DOMAIN, SERVER_UNAVAILABLE
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry, load_json_object_fixture
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_tractive_client() -> Generator[AsyncMock, None, None]:
|
def mock_tractive_client() -> Generator[AsyncMock]:
|
||||||
"""Mock a Tractive client."""
|
"""Mock a Tractive client."""
|
||||||
|
|
||||||
def send_hardware_event(
|
def send_hardware_event(
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable, Generator
|
from collections.abc import Callable
|
||||||
import json
|
import json
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
@ -12,6 +12,7 @@ from pytradfri.command import Command
|
|||||||
from pytradfri.const import ATTR_FIRMWARE_VERSION, ATTR_GATEWAY_ID
|
from pytradfri.const import ATTR_FIRMWARE_VERSION, ATTR_GATEWAY_ID
|
||||||
from pytradfri.device import Device
|
from pytradfri.device import Device
|
||||||
from pytradfri.gateway import Gateway
|
from pytradfri.gateway import Gateway
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tradfri.const import DOMAIN
|
from homeassistant.components.tradfri.const import DOMAIN
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ from tests.common import load_fixture
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_entry_setup() -> Generator[AsyncMock, None, None]:
|
def mock_entry_setup() -> Generator[AsyncMock]:
|
||||||
"""Mock entry setup."""
|
"""Mock entry setup."""
|
||||||
with patch(f"{TRADFRI_PATH}.async_setup_entry") as mock_setup:
|
with patch(f"{TRADFRI_PATH}.async_setup_entry") as mock_setup:
|
||||||
mock_setup.return_value = True
|
mock_setup.return_value = True
|
||||||
@ -76,7 +77,7 @@ def mock_api_fixture(
|
|||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_api_factory(
|
def mock_api_factory(
|
||||||
mock_api: Callable[[Command | list[Command], float | None], Any | None],
|
mock_api: Callable[[Command | list[Command], float | None], Any | None],
|
||||||
) -> Generator[MagicMock, None, None]:
|
) -> Generator[MagicMock]:
|
||||||
"""Mock pytradfri api factory."""
|
"""Mock pytradfri api factory."""
|
||||||
with patch(f"{TRADFRI_PATH}.APIFactory", autospec=True) as factory_class:
|
with patch(f"{TRADFRI_PATH}.APIFactory", autospec=True) as factory_class:
|
||||||
factory = factory_class.return_value
|
factory = factory_class.return_value
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import media_source
|
from homeassistant.components import media_source
|
||||||
@ -42,7 +42,7 @@ SUPPORT_LANGUAGES = ["de_CH", "de_DE", "en_GB", "en_US"]
|
|||||||
TEST_DOMAIN = "test"
|
TEST_DOMAIN = "test"
|
||||||
|
|
||||||
|
|
||||||
def mock_tts_get_cache_files_fixture_helper() -> Generator[MagicMock, None, None]:
|
def mock_tts_get_cache_files_fixture_helper() -> Generator[MagicMock]:
|
||||||
"""Mock the list TTS cache function."""
|
"""Mock the list TTS cache function."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tts._get_cache_files", return_value={}
|
"homeassistant.components.tts._get_cache_files", return_value={}
|
||||||
@ -52,7 +52,7 @@ def mock_tts_get_cache_files_fixture_helper() -> Generator[MagicMock, None, None
|
|||||||
|
|
||||||
def mock_tts_init_cache_dir_fixture_helper(
|
def mock_tts_init_cache_dir_fixture_helper(
|
||||||
init_tts_cache_dir_side_effect: Any,
|
init_tts_cache_dir_side_effect: Any,
|
||||||
) -> Generator[MagicMock, None, None]:
|
) -> Generator[MagicMock]:
|
||||||
"""Mock the TTS cache dir in memory."""
|
"""Mock the TTS cache dir in memory."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tts._init_tts_cache_dir",
|
"homeassistant.components.tts._init_tts_cache_dir",
|
||||||
@ -71,7 +71,7 @@ def mock_tts_cache_dir_fixture_helper(
|
|||||||
mock_tts_init_cache_dir: MagicMock,
|
mock_tts_init_cache_dir: MagicMock,
|
||||||
mock_tts_get_cache_files: MagicMock,
|
mock_tts_get_cache_files: MagicMock,
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
) -> Generator[Path, None, None]:
|
) -> Generator[Path]:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
mock_tts_init_cache_dir.return_value = str(tmp_path)
|
mock_tts_init_cache_dir.return_value = str(tmp_path)
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ def mock_tts_cache_dir_fixture_helper(
|
|||||||
pytest.fail("Test failed, see log for details")
|
pytest.fail("Test failed, see log for details")
|
||||||
|
|
||||||
|
|
||||||
def tts_mutagen_mock_fixture_helper() -> Generator[MagicMock, None, None]:
|
def tts_mutagen_mock_fixture_helper() -> Generator[MagicMock]:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tts.SpeechManager.write_tags",
|
"homeassistant.components.tts.SpeechManager.write_tags",
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
From http://doc.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures
|
From http://doc.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
@ -82,7 +82,7 @@ class TTSFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.tuya.const import CONF_APP_TYPE, CONF_USER_CODE, DOMAIN
|
from homeassistant.components.tuya.const import CONF_APP_TYPE, CONF_USER_CODE, DOMAIN
|
||||||
|
|
||||||
@ -35,14 +35,14 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch("homeassistant.components.tuya.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.tuya.async_setup_entry", return_value=True):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_tuya_login_control() -> Generator[MagicMock, None, None]:
|
def mock_tuya_login_control() -> Generator[MagicMock]:
|
||||||
"""Return a mocked Tuya login control."""
|
"""Return a mocked Tuya login control."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tuya.config_flow.LoginControl", autospec=True
|
"homeassistant.components.tuya.config_flow.LoginControl", autospec=True
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from twentemilieu import WasteType
|
from twentemilieu import WasteType
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.twentemilieu.const import (
|
from homeassistant.components.twentemilieu.const import (
|
||||||
CONF_HOUSE_LETTER,
|
CONF_HOUSE_LETTER,
|
||||||
@ -38,7 +38,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[None, None, None]:
|
def mock_setup_entry() -> Generator[None]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.twentemilieu.async_setup_entry", return_value=True
|
"homeassistant.components.twentemilieu.async_setup_entry", return_value=True
|
||||||
@ -47,7 +47,7 @@ def mock_setup_entry() -> Generator[None, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_twentemilieu() -> Generator[MagicMock, None, None]:
|
def mock_twentemilieu() -> Generator[MagicMock]:
|
||||||
"""Return a mocked Twente Milieu client."""
|
"""Return a mocked Twente Milieu client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
"""Tests for the Twitch component."""
|
"""Tests for the Twitch component."""
|
||||||
|
|
||||||
from collections.abc import AsyncGenerator, AsyncIterator
|
from collections.abc import AsyncIterator
|
||||||
from typing import Any, Generic, TypeVar
|
from typing import Any, Generic, TypeVar
|
||||||
|
|
||||||
from twitchAPI.object.base import TwitchObject
|
from twitchAPI.object.base import TwitchObject
|
||||||
|
from typing_extensions import AsyncGenerator
|
||||||
|
|
||||||
from homeassistant.components.twitch import DOMAIN
|
from homeassistant.components.twitch import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -40,7 +41,7 @@ class TwitchIterObject(Generic[TwitchType]):
|
|||||||
|
|
||||||
async def get_generator(
|
async def get_generator(
|
||||||
fixture: str, target_type: type[TwitchType]
|
fixture: str, target_type: type[TwitchType]
|
||||||
) -> AsyncGenerator[TwitchType, None]:
|
) -> AsyncGenerator[TwitchType]:
|
||||||
"""Return async generator."""
|
"""Return async generator."""
|
||||||
data = load_json_array_fixture(fixture, DOMAIN)
|
data = load_json_array_fixture(fixture, DOMAIN)
|
||||||
async for item in get_generator_from_data(data, target_type):
|
async for item in get_generator_from_data(data, target_type):
|
||||||
@ -49,7 +50,7 @@ async def get_generator(
|
|||||||
|
|
||||||
async def get_generator_from_data(
|
async def get_generator_from_data(
|
||||||
items: list[dict[str, Any]], target_type: type[TwitchType]
|
items: list[dict[str, Any]], target_type: type[TwitchType]
|
||||||
) -> AsyncGenerator[TwitchType, None]:
|
) -> AsyncGenerator[TwitchType]:
|
||||||
"""Return async generator."""
|
"""Return async generator."""
|
||||||
for item in items:
|
for item in items:
|
||||||
yield target_type(**item)
|
yield target_type(**item)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"""Configure tests for the Twitch integration."""
|
"""Configure tests for the Twitch integration."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import time
|
import time
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from twitchAPI.object.api import FollowedChannel, Stream, TwitchUser, UserSubscription
|
from twitchAPI.object.api import FollowedChannel, Stream, TwitchUser, UserSubscription
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.application_credentials import (
|
from homeassistant.components.application_credentials import (
|
||||||
ClientCredential,
|
ClientCredential,
|
||||||
@ -26,7 +26,7 @@ TITLE = "Test"
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.twitch.async_setup_entry", return_value=True
|
"homeassistant.components.twitch.async_setup_entry", return_value=True
|
||||||
@ -93,7 +93,7 @@ def mock_connection(aioclient_mock: AiohttpClientMocker) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def twitch_mock() -> Generator[AsyncMock, None, None]:
|
def twitch_mock() -> Generator[AsyncMock]:
|
||||||
"""Return as fixture to inject other mocks."""
|
"""Return as fixture to inject other mocks."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""The tests for the Update component."""
|
"""The tests for the Update component."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.update import (
|
from homeassistant.components.update import (
|
||||||
ATTR_BACKUP,
|
ATTR_BACKUP,
|
||||||
@ -767,7 +767,7 @@ class MockFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.uptime.const import DOMAIN
|
from homeassistant.components.uptime.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -23,7 +23,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[None, None, None]:
|
def mock_setup_entry() -> Generator[None]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch("homeassistant.components.uptime.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.uptime.async_setup_entry", return_value=True):
|
||||||
yield
|
yield
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Common fixtures for the V2C tests."""
|
"""Common fixtures for the V2C tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytrydan.models.trydan import TrydanData
|
from pytrydan.models.trydan import TrydanData
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.v2c import DOMAIN
|
from homeassistant.components.v2c import DOMAIN
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry, load_json_object_fixture
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.v2c.async_setup_entry", return_value=True
|
"homeassistant.components.v2c.async_setup_entry", return_value=True
|
||||||
@ -34,7 +34,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_v2c_client() -> Generator[AsyncMock, None, None]:
|
def mock_v2c_client() -> Generator[AsyncMock]:
|
||||||
"""Mock a V2C client."""
|
"""Mock a V2C client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
"""Fixtures for Vacuum platform tests."""
|
"""Fixtures for Vacuum platform tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -15,7 +14,7 @@ class MockFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, "test.config_flow")
|
mock_platform(hass, "test.config_flow")
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
"""The tests for Valve."""
|
"""The tests for Valve."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.valve import (
|
from homeassistant.components.valve import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -123,7 +122,7 @@ class MockBinaryValveEntity(ValveEntity):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Fixtures for the Velbus tests."""
|
"""Fixtures for the Velbus tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.velbus.const import DOMAIN
|
from homeassistant.components.velbus.const import DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -16,7 +16,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="controller")
|
@pytest.fixture(name="controller")
|
||||||
def mock_controller() -> Generator[MagicMock, None, None]:
|
def mock_controller() -> Generator[MagicMock]:
|
||||||
"""Mock a successful velbus controller."""
|
"""Mock a successful velbus controller."""
|
||||||
with patch("homeassistant.components.velbus.Velbus", autospec=True) as controller:
|
with patch("homeassistant.components.velbus.Velbus", autospec=True) as controller:
|
||||||
yield controller
|
yield controller
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Tests for the Velbus config flow."""
|
"""Tests for the Velbus config flow."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import serial.tools.list_ports
|
import serial.tools.list_ports
|
||||||
|
from typing_extensions import Generator
|
||||||
from velbusaio.exceptions import VelbusConnectionFailed
|
from velbusaio.exceptions import VelbusConnectionFailed
|
||||||
|
|
||||||
from homeassistant.components import usb
|
from homeassistant.components import usb
|
||||||
@ -39,7 +39,7 @@ def com_port():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="controller")
|
@pytest.fixture(name="controller")
|
||||||
def mock_controller() -> Generator[MagicMock, None, None]:
|
def mock_controller() -> Generator[MagicMock]:
|
||||||
"""Mock a successful velbus controller."""
|
"""Mock a successful velbus controller."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.velbus.config_flow.velbusaio.controller.Velbus",
|
"homeassistant.components.velbus.config_flow.velbusaio.controller.Velbus",
|
||||||
@ -49,7 +49,7 @@ def mock_controller() -> Generator[MagicMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def override_async_setup_entry() -> Generator[AsyncMock, None, None]:
|
def override_async_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.velbus.async_setup_entry", return_value=True
|
"homeassistant.components.velbus.async_setup_entry", return_value=True
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Configuration for Velux tests."""
|
"""Configuration for Velux tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.velux.async_setup_entry", return_value=True
|
"homeassistant.components.velux.async_setup_entry", return_value=True
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.verisure.const import CONF_GIID, DOMAIN
|
from homeassistant.components.verisure.const import CONF_GIID, DOMAIN
|
||||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||||
@ -29,7 +29,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.verisure.async_setup_entry", return_value=True
|
"homeassistant.components.verisure.async_setup_entry", return_value=True
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import AsyncGenerator, Generator
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
||||||
from PyViCare.PyViCareService import ViCareDeviceAccessor, readFeature
|
from PyViCare.PyViCareService import ViCareDeviceAccessor, readFeature
|
||||||
|
from typing_extensions import AsyncGenerator, Generator
|
||||||
|
|
||||||
from homeassistant.components.vicare.const import DOMAIN
|
from homeassistant.components.vicare.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -80,7 +80,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def mock_vicare_gas_boiler(
|
async def mock_vicare_gas_boiler(
|
||||||
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
hass: HomeAssistant, mock_config_entry: MockConfigEntry
|
||||||
) -> AsyncGenerator[MockConfigEntry, None]:
|
) -> AsyncGenerator[MockConfigEntry]:
|
||||||
"""Return a mocked ViCare API representing a single gas boiler device."""
|
"""Return a mocked ViCare API representing a single gas boiler device."""
|
||||||
fixtures: list[Fixture] = [Fixture({"type:boiler"}, "vicare/Vitodens300W.json")]
|
fixtures: list[Fixture] = [Fixture({"type:boiler"}, "vicare/Vitodens300W.json")]
|
||||||
with patch(
|
with patch(
|
||||||
@ -96,7 +96,7 @@ async def mock_vicare_gas_boiler(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry:
|
with patch(f"{MODULE}.async_setup_entry", return_value=True) as mock_setup_entry:
|
||||||
yield mock_setup_entry
|
yield mock_setup_entry
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Vilfo tests conftest."""
|
"""Vilfo tests conftest."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.vilfo import DOMAIN
|
from homeassistant.components.vilfo import DOMAIN
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
|
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
|
||||||
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.vilfo.async_setup_entry",
|
"homeassistant.components.vilfo.async_setup_entry",
|
||||||
@ -22,7 +22,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_vilfo_client() -> Generator[AsyncMock, None, None]:
|
def mock_vilfo_client() -> Generator[AsyncMock]:
|
||||||
"""Mock a Vilfo client."""
|
"""Mock a Vilfo client."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.vilfo.config_flow.VilfoClient",
|
"homeassistant.components.vilfo.config_flow.VilfoClient",
|
||||||
@ -38,7 +38,7 @@ def mock_vilfo_client() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_is_valid_host() -> Generator[AsyncMock, None, None]:
|
def mock_is_valid_host() -> Generator[AsyncMock]:
|
||||||
"""Mock is_valid_host."""
|
"""Mock is_valid_host."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.vilfo.config_flow.is_host_valid",
|
"homeassistant.components.vilfo.config_flow.is_host_valid",
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
"""Test wake_word component setup."""
|
"""Test wake_word component setup."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import AsyncIterable, Generator
|
from collections.abc import AsyncIterable
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components import wake_word
|
from homeassistant.components import wake_word
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState, ConfigFlow
|
from homeassistant.config_entries import ConfigEntry, ConfigEntryState, ConfigFlow
|
||||||
@ -88,7 +89,7 @@ class WakeWordFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Common fixtures for the World Air Quality Index (WAQI) tests."""
|
"""Common fixtures for the World Air Quality Index (WAQI) tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.waqi.const import CONF_STATION_NUMBER, DOMAIN
|
from homeassistant.components.waqi.const import CONF_STATION_NUMBER, DOMAIN
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
@ -12,7 +12,7 @@ from tests.common import MockConfigEntry
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.waqi.async_setup_entry", return_value=True
|
"homeassistant.components.waqi.async_setup_entry", return_value=True
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
"""Fixtures for water heater platform tests."""
|
"""Fixtures for water heater platform tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -15,7 +14,7 @@ class MockFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, "test.config_flow")
|
mock_platform(hass, "test.config_flow")
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
"""Fixtures for Weather platform tests."""
|
"""Fixtures for Weather platform tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow
|
from homeassistant.config_entries import ConfigFlow
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -15,7 +14,7 @@ class MockFlow(ConfigFlow):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config_flow_fixture(hass: HomeAssistant) -> Generator[None, None, None]:
|
def config_flow_fixture(hass: HomeAssistant) -> Generator[None]:
|
||||||
"""Mock config flow."""
|
"""Mock config flow."""
|
||||||
mock_platform(hass, "test.config_flow")
|
mock_platform(hass, "test.config_flow")
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""Fixtures for Weatherflow integration tests."""
|
"""Fixtures for Weatherflow integration tests."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pyweatherflowudp.client import EVENT_DEVICE_DISCOVERED
|
from pyweatherflowudp.client import EVENT_DEVICE_DISCOVERED
|
||||||
from pyweatherflowudp.device import WeatherFlowDevice
|
from pyweatherflowudp.device import WeatherFlowDevice
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.weatherflow.const import DOMAIN
|
from homeassistant.components.weatherflow.const import DOMAIN
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry, load_json_object_fixture
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.weatherflow.async_setup_entry", return_value=True
|
"homeassistant.components.weatherflow.async_setup_entry", return_value=True
|
||||||
@ -29,7 +29,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_has_devices() -> Generator[AsyncMock, None, None]:
|
def mock_has_devices() -> Generator[AsyncMock]:
|
||||||
"""Return a mock has_devices function."""
|
"""Return a mock has_devices function."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.weatherflow.config_flow.WeatherFlowListener.on",
|
"homeassistant.components.weatherflow.config_flow.WeatherFlowListener.on",
|
||||||
@ -39,7 +39,7 @@ def mock_has_devices() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_stop() -> Generator[AsyncMock, None, None]:
|
def mock_stop() -> Generator[AsyncMock]:
|
||||||
"""Return a fixture to handle the stop of udp."""
|
"""Return a fixture to handle the stop of udp."""
|
||||||
|
|
||||||
async def mock_stop_listening(self):
|
async def mock_stop_listening(self):
|
||||||
@ -54,7 +54,7 @@ def mock_stop() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_start() -> Generator[AsyncMock, None, None]:
|
def mock_start() -> Generator[AsyncMock]:
|
||||||
"""Return fixture for starting upd."""
|
"""Return fixture for starting upd."""
|
||||||
|
|
||||||
device = WeatherFlowDevice(
|
device = WeatherFlowDevice(
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
"""Common fixtures for the WeatherflowCloud tests."""
|
"""Common fixtures for the WeatherflowCloud tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from aiohttp import ClientResponseError
|
from aiohttp import ClientResponseError
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.weatherflow_cloud.async_setup_entry",
|
"homeassistant.components.weatherflow_cloud.async_setup_entry",
|
||||||
@ -18,7 +18,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_get_stations() -> Generator[AsyncMock, None, None]:
|
def mock_get_stations() -> Generator[AsyncMock]:
|
||||||
"""Mock get_stations with a sequence of responses."""
|
"""Mock get_stations with a sequence of responses."""
|
||||||
side_effects = [
|
side_effects = [
|
||||||
True,
|
True,
|
||||||
@ -32,7 +32,7 @@ def mock_get_stations() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_get_stations_500_error() -> Generator[AsyncMock, None, None]:
|
def mock_get_stations_500_error() -> Generator[AsyncMock]:
|
||||||
"""Mock get_stations with a sequence of responses."""
|
"""Mock get_stations with a sequence of responses."""
|
||||||
side_effects = [
|
side_effects = [
|
||||||
ClientResponseError(Mock(), (), status=500),
|
ClientResponseError(Mock(), (), status=500),
|
||||||
@ -47,7 +47,7 @@ def mock_get_stations_500_error() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_get_stations_401_error() -> Generator[AsyncMock, None, None]:
|
def mock_get_stations_401_error() -> Generator[AsyncMock]:
|
||||||
"""Mock get_stations with a sequence of responses."""
|
"""Mock get_stations with a sequence of responses."""
|
||||||
side_effects = [ClientResponseError(Mock(), (), status=401), True, True, True]
|
side_effects = [ClientResponseError(Mock(), (), status=401), True, True, True]
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Common fixtures for the Apple WeatherKit tests."""
|
"""Common fixtures for the Apple WeatherKit tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.weatherkit.async_setup_entry", return_value=True
|
"homeassistant.components.weatherkit.async_setup_entry", return_value=True
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Fixtures for Webmin integration tests."""
|
"""Fixtures for Webmin integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.webmin.const import DEFAULT_PORT, DOMAIN
|
from homeassistant.components.webmin.const import DEFAULT_PORT, DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -29,7 +29,7 @@ TEST_USER_INPUT = {
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.webmin.async_setup_entry", return_value=True
|
"homeassistant.components.webmin.async_setup_entry", return_value=True
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Common fixtures and objects for the LG webOS integration tests."""
|
"""Common fixtures and objects for the LG webOS integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.webostv.const import LIVE_TV_APP_ID
|
from homeassistant.components.webostv.const import LIVE_TV_APP_ID
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
@ -14,7 +14,7 @@ from tests.common import async_mock_service
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.webostv.async_setup_entry", return_value=True
|
"homeassistant.components.webostv.async_setup_entry", return_value=True
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
from unittest.mock import AsyncMock, MagicMock, Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.whois.const import DOMAIN
|
from homeassistant.components.whois.const import DOMAIN
|
||||||
from homeassistant.const import CONF_DOMAIN
|
from homeassistant.const import CONF_DOMAIN
|
||||||
@ -30,7 +30,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.whois.async_setup_entry", return_value=True
|
"homeassistant.components.whois.async_setup_entry", return_value=True
|
||||||
@ -39,7 +39,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_whois() -> Generator[MagicMock, None, None]:
|
def mock_whois() -> Generator[MagicMock]:
|
||||||
"""Return a mocked query."""
|
"""Return a mocked query."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -68,7 +68,7 @@ def mock_whois() -> Generator[MagicMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_whois_missing_some_attrs() -> Generator[Mock, None, None]:
|
def mock_whois_missing_some_attrs() -> Generator[Mock]:
|
||||||
"""Return a mocked query that only sets admin."""
|
"""Return a mocked query that only sets admin."""
|
||||||
|
|
||||||
class LimitedWhoisMock:
|
class LimitedWhoisMock:
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Configuration for Wiffi tests."""
|
"""Configuration for Wiffi tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.wiffi.async_setup_entry", return_value=True
|
"homeassistant.components.wiffi.async_setup_entry", return_value=True
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Fixtures for WLED integration tests."""
|
"""Fixtures for WLED integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import AsyncMock, MagicMock, patch
|
||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
from wled import Device as WLEDDevice
|
from wled import Device as WLEDDevice
|
||||||
|
|
||||||
from homeassistant.components.wled.const import DOMAIN
|
from homeassistant.components.wled.const import DOMAIN
|
||||||
@ -26,7 +26,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.wled.async_setup_entry", return_value=True
|
"homeassistant.components.wled.async_setup_entry", return_value=True
|
||||||
@ -35,7 +35,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_onboarding() -> Generator[MagicMock, None, None]:
|
def mock_onboarding() -> Generator[MagicMock]:
|
||||||
"""Mock that Home Assistant is currently onboarding."""
|
"""Mock that Home Assistant is currently onboarding."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.onboarding.async_is_onboarded",
|
"homeassistant.components.onboarding.async_is_onboarded",
|
||||||
@ -51,7 +51,7 @@ def device_fixture() -> str:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_wled(device_fixture: str) -> Generator[MagicMock, None, None]:
|
def mock_wled(device_fixture: str) -> Generator[MagicMock]:
|
||||||
"""Return a mocked WLED client."""
|
"""Return a mocked WLED client."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Fixtures for Workday integration tests."""
|
"""Fixtures for Workday integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.workday.async_setup_entry", return_value=True
|
"homeassistant.components.workday.async_setup_entry", return_value=True
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Common fixtures for the Wyoming tests."""
|
"""Common fixtures for the Wyoming tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components import stt
|
from homeassistant.components import stt
|
||||||
from homeassistant.components.wyoming import DOMAIN
|
from homeassistant.components.wyoming import DOMAIN
|
||||||
@ -31,7 +31,7 @@ async def init_components(hass: HomeAssistant):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.wyoming.async_setup_entry", return_value=True
|
"homeassistant.components.wyoming.async_setup_entry", return_value=True
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
"""Session fixtures."""
|
"""Session fixtures."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
class MockServices:
|
class MockServices:
|
||||||
@ -45,7 +45,7 @@ class MockBleakClientBattery5(MockBleakClient):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_bluetooth(enable_bluetooth: None) -> Generator[None, None, None]:
|
def mock_bluetooth(enable_bluetooth: None) -> Generator[None]:
|
||||||
"""Auto mock bluetooth."""
|
"""Auto mock bluetooth."""
|
||||||
|
|
||||||
with mock.patch("xiaomi_ble.parser.BleakClient", MockBleakClientBattery5):
|
with mock.patch("xiaomi_ble.parser.BleakClient", MockBleakClientBattery5):
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
"""The tests for the Xiaomi vacuum platform."""
|
"""The tests for the Xiaomi vacuum platform."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from datetime import datetime, time, timedelta
|
from datetime import datetime, time, timedelta
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from miio import DeviceException
|
from miio import DeviceException
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components.vacuum import (
|
from homeassistant.components.vacuum import (
|
||||||
ATTR_BATTERY_ICON,
|
ATTR_BATTERY_ICON,
|
||||||
@ -143,7 +143,7 @@ new_fanspeeds = {
|
|||||||
@pytest.fixture(name="mock_mirobo_fanspeeds", params=[old_fanspeeds, new_fanspeeds])
|
@pytest.fixture(name="mock_mirobo_fanspeeds", params=[old_fanspeeds, new_fanspeeds])
|
||||||
def mirobo_old_speeds_fixture(
|
def mirobo_old_speeds_fixture(
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
) -> Generator[MagicMock, None, None]:
|
) -> Generator[MagicMock]:
|
||||||
"""Fixture for testing both types of fanspeeds."""
|
"""Fixture for testing both types of fanspeeds."""
|
||||||
mock_vacuum = MagicMock()
|
mock_vacuum = MagicMock()
|
||||||
mock_vacuum.status().battery = 32
|
mock_vacuum.status().battery = 32
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
"""Common fixtures for the Yardian tests."""
|
"""Common fixtures for the Yardian tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.yardian.async_setup_entry", return_value=True
|
"homeassistant.components.yardian.async_setup_entry", return_value=True
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"""Tests for the YouTube integration."""
|
"""Tests for the YouTube integration."""
|
||||||
|
|
||||||
from collections.abc import AsyncGenerator
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from typing_extensions import AsyncGenerator
|
||||||
from youtubeaio.models import YouTubeChannel, YouTubePlaylistItem, YouTubeSubscription
|
from youtubeaio.models import YouTubeChannel, YouTubePlaylistItem, YouTubeSubscription
|
||||||
from youtubeaio.types import AuthScope
|
from youtubeaio.types import AuthScope
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class MockYouTube:
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Authenticate the user."""
|
"""Authenticate the user."""
|
||||||
|
|
||||||
async def get_user_channels(self) -> AsyncGenerator[YouTubeChannel, None]:
|
async def get_user_channels(self) -> AsyncGenerator[YouTubeChannel]:
|
||||||
"""Get channels for authenticated user."""
|
"""Get channels for authenticated user."""
|
||||||
channels = json.loads(load_fixture(self._channel_fixture))
|
channels = json.loads(load_fixture(self._channel_fixture))
|
||||||
for item in channels["items"]:
|
for item in channels["items"]:
|
||||||
@ -38,7 +38,7 @@ class MockYouTube:
|
|||||||
|
|
||||||
async def get_channels(
|
async def get_channels(
|
||||||
self, channel_ids: list[str]
|
self, channel_ids: list[str]
|
||||||
) -> AsyncGenerator[YouTubeChannel, None]:
|
) -> AsyncGenerator[YouTubeChannel]:
|
||||||
"""Get channels."""
|
"""Get channels."""
|
||||||
if self._thrown_error is not None:
|
if self._thrown_error is not None:
|
||||||
raise self._thrown_error
|
raise self._thrown_error
|
||||||
@ -48,13 +48,13 @@ class MockYouTube:
|
|||||||
|
|
||||||
async def get_playlist_items(
|
async def get_playlist_items(
|
||||||
self, playlist_id: str, amount: int
|
self, playlist_id: str, amount: int
|
||||||
) -> AsyncGenerator[YouTubePlaylistItem, None]:
|
) -> AsyncGenerator[YouTubePlaylistItem]:
|
||||||
"""Get channels."""
|
"""Get channels."""
|
||||||
channels = json.loads(load_fixture(self._playlist_items_fixture))
|
channels = json.loads(load_fixture(self._playlist_items_fixture))
|
||||||
for item in channels["items"]:
|
for item in channels["items"]:
|
||||||
yield YouTubePlaylistItem(**item)
|
yield YouTubePlaylistItem(**item)
|
||||||
|
|
||||||
async def get_user_subscriptions(self) -> AsyncGenerator[YouTubeSubscription, None]:
|
async def get_user_subscriptions(self) -> AsyncGenerator[YouTubeSubscription]:
|
||||||
"""Get channels for authenticated user."""
|
"""Get channels for authenticated user."""
|
||||||
channels = json.loads(load_fixture(self._subscriptions_fixture))
|
channels = json.loads(load_fixture(self._subscriptions_fixture))
|
||||||
for item in channels["items"]:
|
for item in channels["items"]:
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Fixtures for Zamg integration tests."""
|
"""Fixtures for Zamg integration tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
import json
|
import json
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
from zamg import ZamgData as ZamgDevice
|
from zamg import ZamgData as ZamgDevice
|
||||||
|
|
||||||
from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN
|
from homeassistant.components.zamg.const import CONF_STATION_ID, DOMAIN
|
||||||
@ -30,7 +30,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[None, None, None]:
|
def mock_setup_entry() -> Generator[None]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch("homeassistant.components.zamg.async_setup_entry", return_value=True):
|
with patch("homeassistant.components.zamg.async_setup_entry", return_value=True):
|
||||||
yield
|
yield
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Test configuration for the ZHA component."""
|
"""Test configuration for the ZHA component."""
|
||||||
|
|
||||||
from collections.abc import Callable, Generator
|
from collections.abc import Callable
|
||||||
import itertools
|
import itertools
|
||||||
import time
|
import time
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -8,6 +8,7 @@ from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
import zigpy
|
import zigpy
|
||||||
from zigpy.application import ControllerApplication
|
from zigpy.application import ControllerApplication
|
||||||
import zigpy.backups
|
import zigpy.backups
|
||||||
@ -225,7 +226,7 @@ async def config_entry_fixture(hass) -> MockConfigEntry:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_zigpy_connect(
|
def mock_zigpy_connect(
|
||||||
zigpy_app_controller: ControllerApplication,
|
zigpy_app_controller: ControllerApplication,
|
||||||
) -> Generator[ControllerApplication, None, None]:
|
) -> Generator[ControllerApplication]:
|
||||||
"""Patch the zigpy radio connection with our mock application."""
|
"""Patch the zigpy radio connection with our mock application."""
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
"""Tests for ZHA config flow."""
|
"""Tests for ZHA config flow."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
|
||||||
from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
|
from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import serial.tools.list_ports
|
import serial.tools.list_ports
|
||||||
|
from typing_extensions import Generator
|
||||||
from zigpy.backups import BackupManager
|
from zigpy.backups import BackupManager
|
||||||
import zigpy.config
|
import zigpy.config
|
||||||
from zigpy.config import CONF_DEVICE_PATH
|
from zigpy.config import CONF_DEVICE_PATH
|
||||||
@ -87,7 +87,7 @@ def com_port(device="/dev/ttyUSB1234"):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_connect_zigpy_app() -> Generator[MagicMock, None, None]:
|
def mock_connect_zigpy_app() -> Generator[MagicMock]:
|
||||||
"""Mock the radio connection."""
|
"""Mock the radio connection."""
|
||||||
|
|
||||||
mock_connect_app = MagicMock()
|
mock_connect_app = MagicMock()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Test the Z-Wave JS config flow."""
|
"""Test the Z-Wave JS config flow."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Generator
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
from unittest.mock import DEFAULT, MagicMock, call, patch
|
from unittest.mock import DEFAULT, MagicMock, call, patch
|
||||||
@ -9,6 +8,7 @@ from unittest.mock import DEFAULT, MagicMock, call, patch
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest
|
import pytest
|
||||||
from serial.tools.list_ports_common import ListPortInfo
|
from serial.tools.list_ports_common import ListPortInfo
|
||||||
|
from typing_extensions import Generator
|
||||||
from zwave_js_server.version import VersionInfo
|
from zwave_js_server.version import VersionInfo
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@ -159,7 +159,7 @@ def serial_port_fixture() -> ListPortInfo:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_list_ports", autouse=True)
|
@pytest.fixture(name="mock_list_ports", autouse=True)
|
||||||
def mock_list_ports_fixture(serial_port) -> Generator[MagicMock, None, None]:
|
def mock_list_ports_fixture(serial_port) -> Generator[MagicMock]:
|
||||||
"""Mock list ports."""
|
"""Mock list ports."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.zwave_js.config_flow.list_ports.comports"
|
"homeassistant.components.zwave_js.config_flow.list_ports.comports"
|
||||||
@ -179,7 +179,7 @@ def mock_list_ports_fixture(serial_port) -> Generator[MagicMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
|
@pytest.fixture(name="mock_usb_serial_by_id", autouse=True)
|
||||||
def mock_usb_serial_by_id_fixture() -> Generator[MagicMock, None, None]:
|
def mock_usb_serial_by_id_fixture() -> Generator[MagicMock]:
|
||||||
"""Mock usb serial by id."""
|
"""Mock usb serial by id."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.zwave_js.config_flow.usb.get_serial_by_id"
|
"homeassistant.components.zwave_js.config_flow.usb.get_serial_by_id"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user