Replace asynctest with tests.async_mock (#37428)
This commit is contained in:
parent
eb66da6436
commit
0c771f1c42
17 changed files with 22 additions and 25 deletions
|
@ -1,6 +1,5 @@
|
||||||
"""Define tests for the Acmeda config flow."""
|
"""Define tests for the Acmeda config flow."""
|
||||||
import aiopulse
|
import aiopulse
|
||||||
from asynctest.mock import patch
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
|
@ -8,6 +7,7 @@ from homeassistant.components.acmeda.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
DUMMY_HOST1 = "127.0.0.1"
|
DUMMY_HOST1 = "127.0.0.1"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Test the Avri config flow."""
|
"""Test the Avri config flow."""
|
||||||
from asynctest import patch
|
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.avri.const import DOMAIN
|
from homeassistant.components.avri.const import DOMAIN
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
|
|
||||||
|
|
||||||
async def test_form(hass):
|
async def test_form(hass):
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Define tests for the Awair config flow."""
|
"""Define tests for the Awair config flow."""
|
||||||
|
|
||||||
from asynctest import patch
|
|
||||||
from python_awair.exceptions import AuthError, AwairError
|
from python_awair.exceptions import AuthError, AwairError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
|
@ -10,6 +9,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
|
||||||
from .const import CONFIG, DEVICES_FIXTURE, NO_DEVICES_FIXTURE, UNIQUE_ID, USER_FIXTURE
|
from .const import CONFIG, DEVICES_FIXTURE, NO_DEVICES_FIXTURE, UNIQUE_ID, USER_FIXTURE
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Test the Flick Electric config flow."""
|
"""Test the Flick Electric config flow."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from asynctest import patch
|
|
||||||
from pyflick.authentication import AuthException
|
from pyflick.authentication import AuthException
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, data_entry_flow, setup
|
||||||
from homeassistant.components.flick_electric.const import DOMAIN
|
from homeassistant.components.flick_electric.const import DOMAIN
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
CONF = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"}
|
CONF = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
"""Define fixtures for Elexa Guardian tests."""
|
"""Define fixtures for Elexa Guardian tests."""
|
||||||
from asynctest import patch
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def ping_client():
|
def ping_client():
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Define tests for the Elexa Guardian config flow."""
|
"""Define tests for the Elexa Guardian config flow."""
|
||||||
from aioguardian.errors import GuardianError
|
from aioguardian.errors import GuardianError
|
||||||
from asynctest import patch
|
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.guardian import CONF_UID, DOMAIN
|
from homeassistant.components.guardian import CONF_UID, DOMAIN
|
||||||
|
@ -11,6 +10,7 @@ from homeassistant.components.guardian.config_flow import (
|
||||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
"""Test the HomeKit config flow."""
|
"""Test the HomeKit config flow."""
|
||||||
from asynctest import patch
|
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow, setup
|
from homeassistant import config_entries, data_entry_flow, setup
|
||||||
from homeassistant.components.homekit.const import DOMAIN
|
from homeassistant.components.homekit.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT
|
||||||
from homeassistant.const import CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_NAME, CONF_PORT
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import os
|
import os
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from asynctest import MagicMock
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
|
@ -62,7 +61,7 @@ from homeassistant.util import json as json_util
|
||||||
|
|
||||||
from .util import PATH_HOMEKIT, async_init_entry, async_init_integration
|
from .util import PATH_HOMEKIT, async_init_entry, async_init_integration
|
||||||
|
|
||||||
from tests.async_mock import ANY, AsyncMock, Mock, patch
|
from tests.async_mock import ANY, AsyncMock, MagicMock, Mock, patch
|
||||||
from tests.common import MockConfigEntry, mock_device_registry, mock_registry
|
from tests.common import MockConfigEntry, mock_device_registry, mock_registry
|
||||||
from tests.components.homekit.common import patch_debounce
|
from tests.components.homekit.common import patch_debounce
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
"""Test util for the homekit integration."""
|
"""Test util for the homekit integration."""
|
||||||
|
|
||||||
from asynctest import patch
|
|
||||||
|
|
||||||
from homeassistant.components.homekit.const import DOMAIN
|
from homeassistant.components.homekit.const import DOMAIN
|
||||||
from homeassistant.const import CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_NAME, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
PATH_HOMEKIT = "homeassistant.components.homekit"
|
PATH_HOMEKIT = "homeassistant.components.homekit"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Test the JuiceNet config flow."""
|
"""Test the JuiceNet config flow."""
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from asynctest import patch
|
|
||||||
from asynctest.mock import MagicMock
|
|
||||||
from pyjuicenet import TokenError
|
from pyjuicenet import TokenError
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.juicenet.const import DOMAIN
|
from homeassistant.components.juicenet.const import DOMAIN
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
|
|
||||||
|
from tests.async_mock import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
def _mock_juicenet_return_value(get_devices=None):
|
def _mock_juicenet_return_value(get_devices=None):
|
||||||
juicenet_mock = MagicMock()
|
juicenet_mock = MagicMock()
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
"""Test the Panasonic Viera setup process."""
|
"""Test the Panasonic Viera setup process."""
|
||||||
from asynctest import patch
|
|
||||||
|
|
||||||
from homeassistant.components.panasonic_viera.const import (
|
from homeassistant.components.panasonic_viera.const import (
|
||||||
CONF_APP_ID,
|
CONF_APP_ID,
|
||||||
CONF_ENCRYPTION_KEY,
|
CONF_ENCRYPTION_KEY,
|
||||||
|
@ -13,7 +11,7 @@ from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED
|
||||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.async_mock import Mock
|
from tests.async_mock import Mock, patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
MOCK_CONFIG_DATA = {
|
MOCK_CONFIG_DATA = {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Test the Logitech Squeezebox config flow."""
|
"""Test the Logitech Squeezebox config flow."""
|
||||||
from asynctest import patch
|
|
||||||
from pysqueezebox import Server
|
from pysqueezebox import Server
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
@ -17,6 +16,7 @@ from homeassistant.data_entry_flow import (
|
||||||
RESULT_TYPE_FORM,
|
RESULT_TYPE_FORM,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
HOST = "1.1.1.1"
|
HOST = "1.1.1.1"
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
"""Test the UPB Control config flow."""
|
"""Test the UPB Control config flow."""
|
||||||
|
|
||||||
from asynctest import MagicMock, PropertyMock, patch
|
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.upb.const import DOMAIN
|
from homeassistant.components.upb.const import DOMAIN
|
||||||
|
|
||||||
|
from tests.async_mock import MagicMock, PropertyMock, patch
|
||||||
|
|
||||||
|
|
||||||
def mocked_upb(sync_complete=True, config_ok=True):
|
def mocked_upb(sync_complete=True, config_ok=True):
|
||||||
"""Mock UPB lib."""
|
"""Mock UPB lib."""
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""Test the wiffi integration config flow."""
|
"""Test the wiffi integration config flow."""
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
from asynctest import patch
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, data_entry_flow
|
from homeassistant import config_entries, data_entry_flow
|
||||||
|
@ -13,6 +12,7 @@ from homeassistant.data_entry_flow import (
|
||||||
RESULT_TYPE_FORM,
|
RESULT_TYPE_FORM,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
MOCK_CONFIG = {CONF_PORT: 8765}
|
MOCK_CONFIG = {CONF_PORT: 8765}
|
||||||
|
|
|
@ -5,7 +5,6 @@ from typing import Any
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from aiohttp.test_utils import TestClient
|
from aiohttp.test_utils import TestClient
|
||||||
from asynctest import MagicMock
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
from withings_api.common import NotifyAppli, NotifyListProfile, NotifyListResponse
|
from withings_api.common import NotifyAppli, NotifyListProfile, NotifyListResponse
|
||||||
|
@ -18,6 +17,7 @@ from homeassistant.components.withings.common import (
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2Implementation
|
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2Implementation
|
||||||
|
|
||||||
|
from tests.async_mock import MagicMock
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
from tests.components.withings.common import (
|
from tests.components.withings.common import (
|
||||||
ComponentFactory,
|
ComponentFactory,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
"""Test the zerproc config flow."""
|
"""Test the zerproc config flow."""
|
||||||
from asynctest import patch
|
|
||||||
import pyzerproc
|
import pyzerproc
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.zerproc.config_flow import DOMAIN
|
from homeassistant.components.zerproc.config_flow import DOMAIN
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_success(hass):
|
async def test_flow_success(hass):
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
"""Test the zerproc lights."""
|
"""Test the zerproc lights."""
|
||||||
from asynctest import patch
|
|
||||||
import pytest
|
import pytest
|
||||||
import pyzerproc
|
import pyzerproc
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
|
from tests.async_mock import patch
|
||||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue