Use asynctest-mock in most places (#35109)

* Use asynctest-mock in most places

* Fix broken patch in pilight
This commit is contained in:
Paulus Schoutsen 2020-05-03 11:27:19 -07:00 committed by GitHub
parent e7fc886992
commit 2af984917e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
319 changed files with 456 additions and 522 deletions

View file

@ -1,12 +1,12 @@
"""Test the HMAC-based One Time Password (MFA) auth module.""" """Test the HMAC-based One Time Password (MFA) auth module."""
import asyncio import asyncio
from unittest.mock import patch
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.auth import auth_manager_from_config, models as auth_models from homeassistant.auth import auth_manager_from_config, models as auth_models
from homeassistant.auth.mfa_modules import auth_mfa_module_from_config from homeassistant.auth.mfa_modules import auth_mfa_module_from_config
from homeassistant.components.notify import NOTIFY_SERVICE_SCHEMA from homeassistant.components.notify import NOTIFY_SERVICE_SCHEMA
from tests.async_mock import patch
from tests.common import MockUser, async_mock_service from tests.common import MockUser, async_mock_service
MOCK_CODE = "123456" MOCK_CODE = "123456"

View file

@ -1,11 +1,11 @@
"""Test the Time-based One Time Password (MFA) auth module.""" """Test the Time-based One Time Password (MFA) auth module."""
import asyncio import asyncio
from unittest.mock import patch
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.auth import auth_manager_from_config, models as auth_models from homeassistant.auth import auth_manager_from_config, models as auth_models
from homeassistant.auth.mfa_modules import auth_mfa_module_from_config from homeassistant.auth.mfa_modules import auth_mfa_module_from_config
from tests.async_mock import patch
from tests.common import MockUser from tests.common import MockUser
MOCK_CODE = "123456" MOCK_CODE = "123456"

View file

@ -1,6 +1,5 @@
"""Tests for the Home Assistant auth module.""" """Tests for the Home Assistant auth module."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock, patch
import jwt import jwt
import pytest import pytest
@ -12,6 +11,7 @@ from homeassistant.auth.const import MFA_SESSION_EXPIRATION
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from tests.async_mock import Mock, patch
from tests.common import CLIENT_ID, MockUser, ensure_auth_manager_loaded, flush_store from tests.common import CLIENT_ID, MockUser, ensure_auth_manager_loaded, flush_store

View file

@ -1,10 +1,9 @@
"""Common methods used across tests for Abode.""" """Common methods used across tests for Abode."""
from unittest.mock import patch
from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
from tests.common import MockConfigEntry from tests.common import MockConfigEntry

View file

@ -1,6 +1,4 @@
"""Tests for the Abode alarm control panel device.""" """Tests for the Abode alarm control panel device."""
from unittest.mock import PropertyMock, patch
import abodepy.helpers.constants as CONST import abodepy.helpers.constants as CONST
from homeassistant.components.abode import ATTR_DEVICE_ID from homeassistant.components.abode import ATTR_DEVICE_ID
@ -19,6 +17,8 @@ from homeassistant.const import (
from .common import setup_platform from .common import setup_platform
from tests.async_mock import PropertyMock, patch
DEVICE_ID = "alarm_control_panel.abode_alarm" DEVICE_ID = "alarm_control_panel.abode_alarm"

View file

@ -1,12 +1,12 @@
"""Tests for the Abode camera device.""" """Tests for the Abode camera device."""
from unittest.mock import patch
from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, STATE_IDLE from homeassistant.const import ATTR_ENTITY_ID, STATE_IDLE
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
async def test_entity_registry(hass): async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry.""" """Tests that the devices are registered in the entity registry."""

View file

@ -1,12 +1,11 @@
"""Tests for the Abode config flow.""" """Tests for the Abode config flow."""
from unittest.mock import patch
from abodepy.exceptions import AbodeAuthenticationException from abodepy.exceptions import AbodeAuthenticationException
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.components.abode import config_flow from homeassistant.components.abode import config_flow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, HTTP_INTERNAL_SERVER_ERROR from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, HTTP_INTERNAL_SERVER_ERROR
from tests.async_mock import patch
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
CONF_POLLING = "polling" CONF_POLLING = "polling"

View file

@ -1,6 +1,4 @@
"""Tests for the Abode cover device.""" """Tests for the Abode cover device."""
from unittest.mock import patch
from homeassistant.components.abode import ATTR_DEVICE_ID from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.cover import DOMAIN as COVER_DOMAIN from homeassistant.components.cover import DOMAIN as COVER_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
@ -13,6 +11,8 @@ from homeassistant.const import (
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
DEVICE_ID = "cover.garage_door" DEVICE_ID = "cover.garage_door"

View file

@ -1,6 +1,4 @@
"""Tests for the Abode module.""" """Tests for the Abode module."""
from unittest.mock import patch
from homeassistant.components.abode import ( from homeassistant.components.abode import (
DOMAIN as ABODE_DOMAIN, DOMAIN as ABODE_DOMAIN,
SERVICE_CAPTURE_IMAGE, SERVICE_CAPTURE_IMAGE,
@ -11,6 +9,8 @@ from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
async def test_change_settings(hass): async def test_change_settings(hass):
"""Test change_setting service.""" """Test change_setting service."""

View file

@ -1,6 +1,4 @@
"""Tests for the Abode light device.""" """Tests for the Abode light device."""
from unittest.mock import patch
from homeassistant.components.abode import ATTR_DEVICE_ID from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
@ -19,6 +17,8 @@ from homeassistant.const import (
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
DEVICE_ID = "light.living_room_lamp" DEVICE_ID = "light.living_room_lamp"

View file

@ -1,6 +1,4 @@
"""Tests for the Abode lock device.""" """Tests for the Abode lock device."""
from unittest.mock import patch
from homeassistant.components.abode import ATTR_DEVICE_ID from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
@ -13,6 +11,8 @@ from homeassistant.const import (
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
DEVICE_ID = "lock.test_lock" DEVICE_ID = "lock.test_lock"

View file

@ -1,6 +1,4 @@
"""Tests for the Abode switch device.""" """Tests for the Abode switch device."""
from unittest.mock import patch
from homeassistant.components.abode import ( from homeassistant.components.abode import (
DOMAIN as ABODE_DOMAIN, DOMAIN as ABODE_DOMAIN,
SERVICE_TRIGGER_AUTOMATION, SERVICE_TRIGGER_AUTOMATION,
@ -16,6 +14,8 @@ from homeassistant.const import (
from .common import setup_platform from .common import setup_platform
from tests.async_mock import patch
AUTOMATION_ID = "switch.test_automation" AUTOMATION_ID = "switch.test_automation"
AUTOMATION_UID = "47fae27488f74f55b964a81a066c3a01" AUTOMATION_UID = "47fae27488f74f55b964a81a066c3a01"
DEVICE_ID = "switch.test_switch" DEVICE_ID = "switch.test_switch"

View file

@ -1,6 +1,6 @@
"""Define patches used for androidtv tests.""" """Define patches used for androidtv tests."""
from unittest.mock import mock_open, patch from tests.async_mock import mock_open, patch
class AdbDeviceTcpFake: class AdbDeviceTcpFake:

View file

@ -1,7 +1,6 @@
"""The tests for the androidtv platform.""" """The tests for the androidtv platform."""
import base64 import base64
import logging import logging
from unittest.mock import patch
from androidtv.exceptions import LockNotAcquiredException from androidtv.exceptions import LockNotAcquiredException
@ -41,6 +40,8 @@ from homeassistant.setup import async_setup_component
from . import patchers from . import patchers
from tests.async_mock import patch
# Android TV device with Python ADB implementation # Android TV device with Python ADB implementation
CONFIG_ANDROIDTV_PYTHON_ADB = { CONFIG_ANDROIDTV_PYTHON_ADB = {
DOMAIN: { DOMAIN: {

View file

@ -1,7 +1,6 @@
"""The tests for the Home Assistant API component.""" """The tests for the Home Assistant API component."""
# pylint: disable=protected-access # pylint: disable=protected-access
import json import json
from unittest.mock import patch
from aiohttp import web from aiohttp import web
import pytest import pytest
@ -12,6 +11,7 @@ from homeassistant.bootstrap import DATA_LOGGING
import homeassistant.core as ha import homeassistant.core as ha
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
from tests.common import async_mock_service from tests.common import async_mock_service

View file

@ -1,7 +1,6 @@
"""The tests for the APNS component.""" """The tests for the APNS component."""
import io import io
import unittest import unittest
from unittest.mock import Mock, mock_open, patch
from apns2.errors import Unregistered from apns2.errors import Unregistered
import yaml import yaml
@ -11,6 +10,7 @@ import homeassistant.components.notify as notify
from homeassistant.core import State from homeassistant.core import State
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import Mock, mock_open, patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant
CONFIG = { CONFIG = {

View file

@ -1,8 +1,8 @@
"""The tests for the apprise notification platform.""" """The tests for the apprise notification platform."""
from unittest.mock import MagicMock, patch
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import MagicMock, patch
BASE_COMPONENT = "notify" BASE_COMPONENT = "notify"

View file

@ -1,11 +1,10 @@
"""Test APRS device tracker.""" """Test APRS device tracker."""
from unittest.mock import Mock, patch
import aprslib import aprslib
import homeassistant.components.aprs.device_tracker as device_tracker import homeassistant.components.aprs.device_tracker as device_tracker
from homeassistant.const import EVENT_HOMEASSISTANT_START from homeassistant.const import EVENT_HOMEASSISTANT_START
from tests.async_mock import Mock, patch
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
DEFAULT_PORT = 14580 DEFAULT_PORT = 14580

View file

@ -1,6 +1,5 @@
"""The tests for the Netgear Arlo sensors.""" """The tests for the Netgear Arlo sensors."""
from collections import namedtuple from collections import namedtuple
from unittest.mock import MagicMock, patch
import pytest import pytest
@ -12,6 +11,8 @@ from homeassistant.const import (
UNIT_PERCENTAGE, UNIT_PERCENTAGE,
) )
from tests.async_mock import patch
def _get_named_tuple(input_dict): def _get_named_tuple(input_dict):
return namedtuple("Struct", input_dict.keys())(*input_dict.values()) return namedtuple("Struct", input_dict.keys())(*input_dict.values())
@ -94,7 +95,7 @@ def sensor_with_hass_data(default_sensor, hass):
def mock_dispatch(): def mock_dispatch():
"""Mock the dispatcher connect method.""" """Mock the dispatcher connect method."""
target = "homeassistant.components.arlo.sensor.async_dispatcher_connect" target = "homeassistant.components.arlo.sensor.async_dispatcher_connect"
with patch(target, MagicMock()) as _mock: with patch(target) as _mock:
yield _mock yield _mock

View file

@ -1,13 +1,11 @@
"""Tests for the Atag config flow.""" """Tests for the Atag config flow."""
from unittest.mock import PropertyMock
from pyatag import AtagException from pyatag import AtagException
from homeassistant import config_entries, data_entry_flow from homeassistant import config_entries, data_entry_flow
from homeassistant.components.atag import DOMAIN from homeassistant.components.atag import DOMAIN
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_PORT from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_PORT
from tests.async_mock import patch from tests.async_mock import PropertyMock, patch
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
FIXTURE_USER_INPUT = { FIXTURE_USER_INPUT = {

View file

@ -1,10 +1,8 @@
"""The gateway tests for the august platform.""" """The gateway tests for the august platform."""
from unittest.mock import MagicMock
from homeassistant.components.august.const import DOMAIN from homeassistant.components.august.const import DOMAIN
from homeassistant.components.august.gateway import AugustGateway from homeassistant.components.august.gateway import AugustGateway
from tests.async_mock import patch from tests.async_mock import MagicMock, patch
from tests.components.august.mocks import _mock_august_authentication, _mock_get_config from tests.components.august.mocks import _mock_august_authentication, _mock_get_config

View file

@ -1,6 +1,5 @@
"""Integration tests for the auth component.""" """Integration tests for the auth component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
from homeassistant.auth.models import Credentials from homeassistant.auth.models import Credentials
from homeassistant.components import auth from homeassistant.components import auth
@ -10,6 +9,7 @@ from homeassistant.util.dt import utcnow
from . import async_setup_auth from . import async_setup_auth
from tests.async_mock import patch
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI, MockUser from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI, MockUser

View file

@ -1,8 +1,7 @@
"""Tests for the login flow.""" """Tests for the login flow."""
from unittest.mock import patch
from . import async_setup_auth from . import async_setup_auth
from tests.async_mock import patch
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI

View file

@ -1,11 +1,9 @@
"""The tests for the Event automation.""" """The tests for the Event automation."""
from unittest.mock import patch
import homeassistant.components.automation as automation import homeassistant.components.automation as automation
from homeassistant.core import CoreState from homeassistant.core import CoreState
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import AsyncMock from tests.async_mock import AsyncMock, patch
from tests.common import async_mock_service from tests.common import async_mock_service

View file

@ -1,6 +1,5 @@
"""The tests for the automation component.""" """The tests for the automation component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock, patch
import pytest import pytest
@ -19,6 +18,7 @@ from homeassistant.exceptions import HomeAssistantError, Unauthorized
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import Mock, patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
async_fire_time_changed, async_fire_time_changed,

View file

@ -1,6 +1,5 @@
"""The tests for numeric state automation.""" """The tests for numeric state automation."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
import pytest import pytest
import voluptuous as vol import voluptuous as vol
@ -11,6 +10,7 @@ from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
async_fire_time_changed, async_fire_time_changed,

View file

@ -1,6 +1,5 @@
"""The test for state automation.""" """The test for state automation."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
import pytest import pytest
@ -9,6 +8,7 @@ from homeassistant.core import Context
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
async_fire_time_changed, async_fire_time_changed,

View file

@ -1,6 +1,5 @@
"""The tests for the sun automation.""" """The tests for the sun automation."""
from datetime import datetime from datetime import datetime
from unittest.mock import patch
import pytest import pytest
@ -10,6 +9,7 @@ from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import async_fire_time_changed, async_mock_service, mock_component from tests.common import async_fire_time_changed, async_mock_service, mock_component
from tests.components.automation import common from tests.components.automation import common

View file

@ -1,6 +1,5 @@
"""The tests for the time automation.""" """The tests for the time automation."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
import pytest import pytest
@ -8,6 +7,7 @@ import homeassistant.components.automation as automation
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
async_fire_time_changed, async_fire_time_changed,

View file

@ -1,12 +1,10 @@
"""Test Axis component setup process.""" """Test Axis component setup process."""
from unittest.mock import Mock, patch
from homeassistant.components import axis from homeassistant.components import axis
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from .test_device import MAC, setup_axis_integration from .test_device import MAC, setup_axis_integration
from tests.async_mock import AsyncMock from tests.async_mock import AsyncMock, Mock, patch
from tests.common import MockConfigEntry from tests.common import MockConfigEntry

View file

@ -1,13 +1,13 @@
"""Axis switch platform tests.""" """Axis switch platform tests."""
from unittest.mock import Mock, call as mock_call
from homeassistant.components import axis from homeassistant.components import axis
import homeassistant.components.switch as switch import homeassistant.components.switch as switch
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from .test_device import NAME, setup_axis_integration from .test_device import NAME, setup_axis_integration
from tests.async_mock import Mock, call as mock_call
EVENTS = [ EVENTS = [
{ {
"operation": "Initialized", "operation": "Initialized",

View file

@ -1,6 +1,5 @@
"""The test for binary_sensor device automation.""" """The test for binary_sensor device automation."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
import pytest import pytest
@ -12,6 +11,7 @@ from homeassistant.helpers import device_registry
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
MockConfigEntry, MockConfigEntry,
async_get_device_automation_capabilities, async_get_device_automation_capabilities,

View file

@ -1,7 +1,6 @@
"""Test Bluetooth LE device tracker.""" """Test Bluetooth LE device tracker."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
from homeassistant.components.bluetooth_le_tracker import device_tracker from homeassistant.components.bluetooth_le_tracker import device_tracker
from homeassistant.components.device_tracker.const import ( from homeassistant.components.device_tracker.const import (
@ -13,6 +12,7 @@ from homeassistant.const import CONF_PLATFORM
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util, slugify from homeassistant.util import dt as dt_util, slugify
from tests.async_mock import patch
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed

View file

@ -2,7 +2,6 @@
import json import json
import re import re
import unittest import unittest
from unittest.mock import patch
from urllib.parse import urlparse from urllib.parse import urlparse
import requests import requests
@ -11,6 +10,7 @@ from homeassistant.components import sensor
from homeassistant.components.bom.sensor import BOMCurrentData from homeassistant.components.bom.sensor import BOMCurrentData
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import assert_setup_component, get_test_home_assistant, load_fixture from tests.common import assert_setup_component, get_test_home_assistant, load_fixture
VALID_CONFIG = { VALID_CONFIG = {

View file

@ -1,7 +1,6 @@
"""The tests for the broadlink component.""" """The tests for the broadlink component."""
from base64 import b64decode from base64 import b64decode
from datetime import timedelta from datetime import timedelta
from unittest.mock import MagicMock, call, patch
import pytest import pytest
@ -9,6 +8,8 @@ from homeassistant.components.broadlink import async_setup_service, data_packet
from homeassistant.components.broadlink.const import DOMAIN, SERVICE_LEARN, SERVICE_SEND from homeassistant.components.broadlink.const import DOMAIN, SERVICE_LEARN, SERVICE_SEND
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from tests.async_mock import MagicMock, call, patch
DUMMY_IR_PACKET = ( DUMMY_IR_PACKET = (
"JgBGAJKVETkRORA6ERQRFBEUERQRFBE5ETkQOhAVEBUQFREUEBUQ" "JgBGAJKVETkRORA6ERQRFBEUERQRFBE5ETkQOhAVEBUQFREUEBUQ"
"OhEUERQRORE5EBURFBA6EBUQOhE5EBUQFRA6EDoRFBEADQUAAA==" "OhEUERQRORE5EBURFBA6EBUQOhE5EBUQFRA6EDoRFBEADQUAAA=="

View file

@ -1,6 +1,5 @@
"""The tests for the webdav calendar component.""" """The tests for the webdav calendar component."""
import datetime import datetime
from unittest.mock import MagicMock, Mock
from caldav.objects import Event from caldav.objects import Event
import pytest import pytest
@ -9,7 +8,7 @@ from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import dt from homeassistant.util import dt
from tests.async_mock import patch from tests.async_mock import MagicMock, Mock, patch
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name

View file

@ -2,7 +2,6 @@
import asyncio import asyncio
import base64 import base64
import io import io
from unittest.mock import PropertyMock, mock_open
import pytest import pytest
@ -14,7 +13,7 @@ from homeassistant.const import ATTR_ENTITY_ID, EVENT_HOMEASSISTANT_START
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch from tests.async_mock import PropertyMock, mock_open, patch
from tests.components.camera import common from tests.components.camera import common

View file

@ -1,10 +1,10 @@
"""The tests for the Canary component.""" """The tests for the Canary component."""
import unittest import unittest
from unittest.mock import MagicMock, PropertyMock, patch
from homeassistant import setup from homeassistant import setup
import homeassistant.components.canary as canary import homeassistant.components.canary as canary
from tests.async_mock import MagicMock, PropertyMock, patch
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant

View file

@ -1,7 +1,6 @@
"""The tests for the Canary sensor platform.""" """The tests for the Canary sensor platform."""
import copy import copy
import unittest import unittest
from unittest.mock import Mock
from homeassistant.components.canary import DATA_CANARY, sensor as canary from homeassistant.components.canary import DATA_CANARY, sensor as canary
from homeassistant.components.canary.sensor import ( from homeassistant.components.canary.sensor import (
@ -14,6 +13,7 @@ from homeassistant.components.canary.sensor import (
) )
from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE from homeassistant.const import TEMP_CELSIUS, UNIT_PERCENTAGE
from tests.async_mock import Mock
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant
from tests.components.canary.test_init import mock_device, mock_location from tests.components.canary.test_init import mock_device, mock_location

View file

@ -1,8 +1,7 @@
"""Test Home Assistant Cast.""" """Test Home Assistant Cast."""
from unittest.mock import Mock, patch
from homeassistant.components.cast import home_assistant_cast from homeassistant.components.cast import home_assistant_cast
from tests.async_mock import Mock, patch
from tests.common import MockConfigEntry, async_mock_signal from tests.common import MockConfigEntry, async_mock_signal

View file

@ -1,6 +1,5 @@
"""The tests for the climate component.""" """The tests for the climate component."""
from typing import List from typing import List
from unittest.mock import MagicMock
import pytest import pytest
import voluptuous as vol import voluptuous as vol
@ -13,6 +12,7 @@ from homeassistant.components.climate import (
ClimateEntity, ClimateEntity,
) )
from tests.async_mock import MagicMock
from tests.common import async_mock_service from tests.common import async_mock_service

View file

@ -1,6 +1,4 @@
"""Fixtures for cloud tests.""" """Fixtures for cloud tests."""
from unittest.mock import patch
import jwt import jwt
import pytest import pytest
@ -8,6 +6,8 @@ from homeassistant.components.cloud import const, prefs
from . import mock_cloud, mock_cloud_prefs from . import mock_cloud, mock_cloud_prefs
from tests.async_mock import patch
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_user_data(): def mock_user_data():

View file

@ -1,10 +1,8 @@
"""Tests for the cloud binary sensor.""" """Tests for the cloud binary sensor."""
from unittest.mock import Mock
from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch from tests.async_mock import Mock, patch
async def test_remote_connection_sensor(hass): async def test_remote_connection_sensor(hass):

View file

@ -1,6 +1,4 @@
"""Test the Cloud Google Config.""" """Test the Cloud Google Config."""
from unittest.mock import Mock
from homeassistant.components.cloud import GACTIONS_SCHEMA from homeassistant.components.cloud import GACTIONS_SCHEMA
from homeassistant.components.cloud.google_config import CloudGoogleConfig from homeassistant.components.cloud.google_config import CloudGoogleConfig
from homeassistant.components.google_assistant import helpers as ga_helpers from homeassistant.components.google_assistant import helpers as ga_helpers
@ -9,7 +7,7 @@ from homeassistant.core import CoreState
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from tests.async_mock import AsyncMock, patch from tests.async_mock import AsyncMock, Mock, patch
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed

View file

@ -1,9 +1,9 @@
"""Test Cloud preferences.""" """Test Cloud preferences."""
from unittest.mock import patch
from homeassistant.auth.const import GROUP_ID_ADMIN from homeassistant.auth.const import GROUP_ID_ADMIN
from homeassistant.components.cloud.prefs import STORAGE_KEY, CloudPreferences from homeassistant.components.cloud.prefs import STORAGE_KEY, CloudPreferences
from tests.async_mock import patch
async def test_set_username(hass): async def test_set_username(hass):
"""Test we clear config if we set different username.""" """Test we clear config if we set different username."""

View file

@ -1,11 +1,11 @@
"""Tests for the CoinMarketCap sensor platform.""" """Tests for the CoinMarketCap sensor platform."""
import json import json
import unittest import unittest
from unittest.mock import patch
import homeassistant.components.sensor as sensor import homeassistant.components.sensor as sensor
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import assert_setup_component, get_test_home_assistant, load_fixture from tests.common import assert_setup_component, get_test_home_assistant, load_fixture
VALID_CONFIG = { VALID_CONFIG = {

View file

@ -2,11 +2,11 @@
import os import os
import tempfile import tempfile
import unittest import unittest
from unittest.mock import patch
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant

View file

@ -1,10 +1,10 @@
"""The tests for the Command line sensor platform.""" """The tests for the Command line sensor platform."""
import unittest import unittest
from unittest.mock import patch
from homeassistant.components.command_line import sensor as command_line from homeassistant.components.command_line import sensor as command_line
from homeassistant.helpers.template import Template from homeassistant.helpers.template import Template
from tests.async_mock import patch
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant

View file

@ -1,11 +1,10 @@
"""Test Group config panel.""" """Test Group config panel."""
import json import json
from unittest.mock import patch
from homeassistant.bootstrap import async_setup_component from homeassistant.bootstrap import async_setup_component
from homeassistant.components import config from homeassistant.components import config
from tests.async_mock import AsyncMock from tests.async_mock import AsyncMock, patch
VIEW_NAME = "api:config:group:config" VIEW_NAME = "api:config:group:config"

View file

@ -1,9 +1,9 @@
"""Tests for config/script.""" """Tests for config/script."""
from unittest.mock import patch
from homeassistant.bootstrap import async_setup_component from homeassistant.bootstrap import async_setup_component
from homeassistant.components import config from homeassistant.components import config
from tests.async_mock import patch
async def test_delete_script(hass, hass_client): async def test_delete_script(hass, hass_client):
"""Test deleting a script.""" """Test deleting a script."""

View file

@ -1,6 +1,5 @@
"""Test Z-Wave config panel.""" """Test Z-Wave config panel."""
import json import json
from unittest.mock import MagicMock, patch
import pytest import pytest
@ -9,6 +8,7 @@ from homeassistant.components import config
from homeassistant.components.zwave import DATA_NETWORK, const from homeassistant.components.zwave import DATA_NETWORK, const
from homeassistant.const import HTTP_NOT_FOUND from homeassistant.const import HTTP_NOT_FOUND
from tests.async_mock import MagicMock, patch
from tests.mock.zwave import MockEntityValues, MockNode, MockValue from tests.mock.zwave import MockEntityValues, MockNode, MockValue
VIEW_NAME = "api:config:zwave:device_config" VIEW_NAME = "api:config:zwave:device_config"

View file

@ -1,7 +1,6 @@
# pylint: disable=redefined-outer-name # pylint: disable=redefined-outer-name
"""Tests for the Daikin config flow.""" """Tests for the Daikin config flow."""
import asyncio import asyncio
from unittest.mock import patch
import pytest import pytest
@ -10,6 +9,7 @@ from homeassistant.components.daikin import config_flow
from homeassistant.components.daikin.const import KEY_IP, KEY_MAC from homeassistant.components.daikin.const import KEY_IP, KEY_MAC
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
MAC = "AABBCCDDEEFF" MAC = "AABBCCDDEEFF"

View file

@ -2,7 +2,6 @@
from datetime import timedelta from datetime import timedelta
import re import re
import unittest import unittest
from unittest.mock import MagicMock, patch
import forecastio import forecastio
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@ -11,6 +10,7 @@ import requests_mock
from homeassistant.components.darksky import sensor as darksky from homeassistant.components.darksky import sensor as darksky
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import MagicMock, patch
from tests.common import get_test_home_assistant, load_fixture from tests.common import get_test_home_assistant, load_fixture
VALID_CONFIG_MINIMAL = { VALID_CONFIG_MINIMAL = {

View file

@ -1,7 +1,6 @@
"""The tests for the Dark Sky weather component.""" """The tests for the Dark Sky weather component."""
import re import re
import unittest import unittest
from unittest.mock import patch
import forecastio import forecastio
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
@ -11,6 +10,7 @@ from homeassistant.components import weather
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from homeassistant.util.unit_system import METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM
from tests.async_mock import patch
from tests.common import get_test_home_assistant, load_fixture from tests.common import get_test_home_assistant, load_fixture

View file

@ -1,10 +1,10 @@
"""Test the default_config init.""" """Test the default_config init."""
from unittest.mock import patch
import pytest import pytest
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def recorder_url_mock(): def recorder_url_mock():

View file

@ -1,6 +1,4 @@
"""The tests for local file camera component.""" """The tests for local file camera component."""
from unittest.mock import patch
import pytest import pytest
from homeassistant.components.camera import ( from homeassistant.components.camera import (
@ -18,6 +16,8 @@ from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
ENTITY_CAMERA = "camera.demo_camera" ENTITY_CAMERA = "camera.demo_camera"

View file

@ -1,6 +1,5 @@
"""The tests for the demo platform.""" """The tests for the demo platform."""
import unittest import unittest
from unittest.mock import patch
from homeassistant.components import geo_location from homeassistant.components import geo_location
from homeassistant.components.demo.geo_location import ( from homeassistant.components.demo.geo_location import (
@ -11,6 +10,7 @@ from homeassistant.const import LENGTH_KILOMETERS
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
fire_time_changed, fire_time_changed,

View file

@ -1,6 +1,5 @@
"""The tests for the notify demo platform.""" """The tests for the notify demo platform."""
import unittest import unittest
from unittest.mock import patch
import pytest import pytest
import voluptuous as vol import voluptuous as vol
@ -11,6 +10,7 @@ from homeassistant.core import callback
from homeassistant.helpers import discovery from homeassistant.helpers import discovery
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant
from tests.components.notify import common from tests.components.notify import common

View file

@ -1,6 +1,4 @@
"""The tests for the denonavr media player platform.""" """The tests for the denonavr media player platform."""
from unittest.mock import patch
import pytest import pytest
from homeassistant.components import media_player from homeassistant.components import media_player
@ -8,6 +6,8 @@ from homeassistant.components.denonavr import ATTR_COMMAND, DOMAIN, SERVICE_GET_
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_PLATFORM from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_NAME, CONF_PLATFORM
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
NAME = "fake" NAME = "fake"
ENTITY_ID = f"{media_player.DOMAIN}.{NAME}" ENTITY_ID = f"{media_player.DOMAIN}.{NAME}"

View file

@ -1,11 +1,12 @@
"""The tests for the derivative sensor platform.""" """The tests for the derivative sensor platform."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import patch
from homeassistant.const import POWER_WATT, TIME_HOURS, TIME_MINUTES, TIME_SECONDS from homeassistant.const import POWER_WATT, TIME_HOURS, TIME_MINUTES, TIME_SECONDS
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
async def test_state(hass): async def test_state(hass):
"""Test derivative sensor state.""" """Test derivative sensor state."""

View file

@ -1,7 +1,6 @@
"""The tests for the Dialogflow component.""" """The tests for the Dialogflow component."""
import copy import copy
import json import json
from unittest.mock import Mock
import pytest import pytest
@ -10,6 +9,8 @@ from homeassistant.components import dialogflow, intent_script
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import Mock
SESSION_ID = "a9b84cec-46b6-484e-8f31-f65dba03ae6d" SESSION_ID = "a9b84cec-46b6-484e-8f31-f65dba03ae6d"
INTENT_ID = "c6a74079-a8f0-46cd-b372-5a934d23591c" INTENT_ID = "c6a74079-a8f0-46cd-b372-5a934d23591c"
INTENT_NAME = "tests" INTENT_NAME = "tests"

View file

@ -9,7 +9,6 @@ import asyncio
import datetime import datetime
from decimal import Decimal from decimal import Decimal
from itertools import chain, repeat from itertools import chain, repeat
from unittest.mock import DEFAULT, Mock
import pytest import pytest
@ -18,6 +17,7 @@ from homeassistant.components.dsmr.sensor import DerivativeDSMREntity
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TIME_HOURS, VOLUME_CUBIC_METERS from homeassistant.const import ENERGY_KILO_WATT_HOUR, TIME_HOURS, VOLUME_CUBIC_METERS
import tests.async_mock import tests.async_mock
from tests.async_mock import DEFAULT, Mock
from tests.common import assert_setup_component from tests.common import assert_setup_component

View file

@ -2,7 +2,6 @@
from datetime import timedelta from datetime import timedelta
from ipaddress import ip_address from ipaddress import ip_address
import json import json
from unittest.mock import patch
from aiohttp.hdrs import CONTENT_TYPE from aiohttp.hdrs import CONTENT_TYPE
import pytest import pytest
@ -42,6 +41,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 ( from tests.common import (
async_fire_time_changed, async_fire_time_changed,
async_mock_service, async_mock_service,

View file

@ -1,8 +1,8 @@
"""Test the Emulated Hue component.""" """Test the Emulated Hue component."""
from unittest.mock import MagicMock, Mock, patch
from homeassistant.components.emulated_hue import Config from homeassistant.components.emulated_hue import Config
from tests.async_mock import MagicMock, Mock, patch
def test_config_google_home_entity_id_to_number(): def test_config_google_home_entity_id_to_number():
"""Test config adheres to the type.""" """Test config adheres to the type."""

View file

@ -1,7 +1,6 @@
"""The tests for the emulated Hue component.""" """The tests for the emulated Hue component."""
import json import json
import unittest import unittest
from unittest.mock import patch
from aiohttp.hdrs import CONTENT_TYPE from aiohttp.hdrs import CONTENT_TYPE
import defusedxml.ElementTree as ET import defusedxml.ElementTree as ET
@ -10,6 +9,7 @@ import requests
from homeassistant import const, setup from homeassistant import const, setup
from homeassistant.components import emulated_hue from homeassistant.components import emulated_hue
from tests.async_mock import patch
from tests.common import get_test_home_assistant, get_test_instance_port from tests.common import get_test_home_assistant, get_test_instance_port
HTTP_SERVER_PORT = get_test_instance_port() HTTP_SERVER_PORT = get_test_instance_port()

View file

@ -1,6 +1,4 @@
"""Tests for emulated_roku library bindings.""" """Tests for emulated_roku library bindings."""
from unittest.mock import Mock, patch
from homeassistant.components.emulated_roku.binding import ( from homeassistant.components.emulated_roku.binding import (
ATTR_APP_ID, ATTR_APP_ID,
ATTR_COMMAND_TYPE, ATTR_COMMAND_TYPE,
@ -14,7 +12,7 @@ from homeassistant.components.emulated_roku.binding import (
EmulatedRoku, EmulatedRoku,
) )
from tests.async_mock import AsyncMock from tests.async_mock import AsyncMock, Mock, patch
async def test_events_fired_properly(hass): async def test_events_fired_properly(hass):

View file

@ -1,10 +1,8 @@
"""Test emulated_roku component setup process.""" """Test emulated_roku component setup process."""
from unittest.mock import Mock, patch
from homeassistant.components import emulated_roku from homeassistant.components import emulated_roku
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import AsyncMock from tests.async_mock import AsyncMock, Mock, patch
async def test_config_required_fields(hass): async def test_config_required_fields(hass):

View file

@ -1,6 +1,4 @@
"""The tests for the facebox component.""" """The tests for the facebox component."""
from unittest.mock import Mock, mock_open, patch
import pytest import pytest
import requests import requests
import requests_mock import requests_mock
@ -23,6 +21,8 @@ from homeassistant.const import (
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import Mock, mock_open, patch
MOCK_IP = "192.168.0.1" MOCK_IP = "192.168.0.1"
MOCK_PORT = "8080" MOCK_PORT = "8080"

View file

@ -1,6 +1,5 @@
"""The tests for local file sensor platform.""" """The tests for local file sensor platform."""
import unittest import unittest
from unittest.mock import Mock, patch
from mock_open import MockOpen from mock_open import MockOpen
@ -12,6 +11,7 @@ from homeassistant.components.fail2ban.sensor import (
) )
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import Mock, patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant

View file

@ -6,7 +6,6 @@ from os.path import exists
import time import time
import unittest import unittest
from unittest import mock from unittest import mock
from unittest.mock import patch
from homeassistant.components import feedreader from homeassistant.components import feedreader
from homeassistant.components.feedreader import ( from homeassistant.components.feedreader import (
@ -22,6 +21,7 @@ from homeassistant.const import CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_START
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import get_test_home_assistant, load_fixture from tests.common import get_test_home_assistant, load_fixture
_LOGGER = getLogger(__name__) _LOGGER = getLogger(__name__)

View file

@ -1,6 +1,4 @@
"""The tests for Home Assistant ffmpeg.""" """The tests for Home Assistant ffmpeg."""
from unittest.mock import MagicMock
import homeassistant.components.ffmpeg as ffmpeg import homeassistant.components.ffmpeg as ffmpeg
from homeassistant.components.ffmpeg import ( from homeassistant.components.ffmpeg import (
DOMAIN, DOMAIN,
@ -12,6 +10,7 @@ from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.setup import async_setup_component, setup_component from homeassistant.setup import async_setup_component, setup_component
from tests.async_mock import MagicMock
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant

View file

@ -1,11 +1,11 @@
"""The test for the fido sensor platform.""" """The test for the fido sensor platform."""
import logging import logging
import sys import sys
from unittest.mock import MagicMock, patch
from homeassistant.bootstrap import async_setup_component from homeassistant.bootstrap import async_setup_component
from homeassistant.components.fido import sensor as fido from homeassistant.components.fido import sensor as fido
from tests.async_mock import MagicMock, patch
from tests.common import assert_setup_component from tests.common import assert_setup_component
CONTRACT = "123456789" CONTRACT = "123456789"

View file

@ -1,13 +1,13 @@
"""The tests for the notify file platform.""" """The tests for the notify file platform."""
import os import os
import unittest import unittest
from unittest.mock import call, mock_open, patch
import homeassistant.components.notify as notify import homeassistant.components.notify as notify
from homeassistant.components.notify import ATTR_TITLE_DEFAULT from homeassistant.components.notify import ATTR_TITLE_DEFAULT
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import call, mock_open, patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant

View file

@ -1,6 +1,5 @@
"""The tests for local file sensor platform.""" """The tests for local file sensor platform."""
import unittest import unittest
from unittest.mock import Mock, patch
# Using third party package because of a bug reading binary data in Python 3.4 # Using third party package because of a bug reading binary data in Python 3.4
# https://bugs.python.org/issue23004 # https://bugs.python.org/issue23004
@ -9,6 +8,7 @@ from mock_open import MockOpen
from homeassistant.const import STATE_UNKNOWN from homeassistant.const import STATE_UNKNOWN
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import Mock, patch
from tests.common import get_test_home_assistant, mock_registry from tests.common import get_test_home_assistant, mock_registry

View file

@ -1,7 +1,6 @@
"""The test for the data filter sensor platform.""" """The test for the data filter sensor platform."""
from datetime import timedelta from datetime import timedelta
import unittest import unittest
from unittest.mock import patch
from homeassistant.components.filter.sensor import ( from homeassistant.components.filter.sensor import (
LowPassFilter, LowPassFilter,
@ -15,6 +14,7 @@ import homeassistant.core as ha
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
get_test_home_assistant, get_test_home_assistant,

View file

@ -1,10 +1,11 @@
"""The tests for the folder_watcher component.""" """The tests for the folder_watcher component."""
import os import os
from unittest.mock import Mock, patch
from homeassistant.components import folder_watcher from homeassistant.components import folder_watcher
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import Mock, patch
async def test_invalid_path_setup(hass): async def test_invalid_path_setup(hass):
"""Test that an invalid path is not set up.""" """Test that an invalid path is not set up."""

View file

@ -2,7 +2,6 @@
import asyncio import asyncio
import re import re
from unittest.mock import MagicMock
import pytest import pytest
@ -20,6 +19,7 @@ from homeassistant.const import (
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import MagicMock
from tests.common import load_fixture from tests.common import load_fixture
VALID_CONFIG = { VALID_CONFIG = {

View file

@ -1,8 +1,8 @@
"""Test helpers for Freebox.""" """Test helpers for Freebox."""
from unittest.mock import patch
import pytest import pytest
from tests.async_mock import patch
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def mock_path(): def mock_path():

View file

@ -1,9 +1,9 @@
"""Tests for the AVM Fritz!Box integration.""" """Tests for the AVM Fritz!Box integration."""
from unittest.mock import Mock
from homeassistant.components.fritzbox.const import DOMAIN from homeassistant.components.fritzbox.const import DOMAIN
from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_PASSWORD, CONF_USERNAME
from tests.async_mock import Mock
MOCK_CONFIG = { MOCK_CONFIG = {
DOMAIN: { DOMAIN: {
CONF_DEVICES: [ CONF_DEVICES: [

View file

@ -1,8 +1,8 @@
"""Fixtures for the AVM Fritz!Box integration.""" """Fixtures for the AVM Fritz!Box integration."""
from unittest.mock import Mock, patch
import pytest import pytest
from tests.async_mock import Mock, patch
@pytest.fixture(name="fritz") @pytest.fixture(name="fritz")
def fritz_fixture() -> Mock: def fritz_fixture() -> Mock:

View file

@ -1,7 +1,6 @@
"""Tests for AVM Fritz!Box binary sensor component.""" """Tests for AVM Fritz!Box binary sensor component."""
from datetime import timedelta from datetime import timedelta
from unittest import mock from unittest import mock
from unittest.mock import Mock
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@ -19,6 +18,7 @@ import homeassistant.util.dt as dt_util
from . import MOCK_CONFIG, FritzDeviceBinarySensorMock from . import MOCK_CONFIG, FritzDeviceBinarySensorMock
from tests.async_mock import Mock
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
ENTITY_ID = f"{DOMAIN}.fake_name" ENTITY_ID = f"{DOMAIN}.fake_name"

View file

@ -1,6 +1,5 @@
"""Tests for AVM Fritz!Box climate component.""" """Tests for AVM Fritz!Box climate component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock, call
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@ -42,6 +41,7 @@ import homeassistant.util.dt as dt_util
from . import MOCK_CONFIG, FritzDeviceClimateMock from . import MOCK_CONFIG, FritzDeviceClimateMock
from tests.async_mock import Mock, call
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
ENTITY_ID = f"{DOMAIN}.fake_name" ENTITY_ID = f"{DOMAIN}.fake_name"

View file

@ -1,6 +1,5 @@
"""Tests for AVM Fritz!Box config flow.""" """Tests for AVM Fritz!Box config flow."""
from unittest import mock from unittest import mock
from unittest.mock import Mock, patch
from pyfritzhome import LoginError from pyfritzhome import LoginError
import pytest import pytest
@ -17,6 +16,8 @@ from homeassistant.helpers.typing import HomeAssistantType
from . import MOCK_CONFIG from . import MOCK_CONFIG
from tests.async_mock import Mock, patch
MOCK_USER_DATA = MOCK_CONFIG[DOMAIN][CONF_DEVICES][0] MOCK_USER_DATA = MOCK_CONFIG[DOMAIN][CONF_DEVICES][0]
MOCK_SSDP_DATA = { MOCK_SSDP_DATA = {
ATTR_SSDP_LOCATION: "https://fake_host:12345/test", ATTR_SSDP_LOCATION: "https://fake_host:12345/test",

View file

@ -1,6 +1,4 @@
"""Tests for the AVM Fritz!Box integration.""" """Tests for the AVM Fritz!Box integration."""
from unittest.mock import Mock, call
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED
@ -10,6 +8,7 @@ from homeassistant.setup import async_setup_component
from . import MOCK_CONFIG, FritzDeviceSwitchMock from . import MOCK_CONFIG, FritzDeviceSwitchMock
from tests.async_mock import Mock, call
from tests.common import MockConfigEntry from tests.common import MockConfigEntry

View file

@ -1,6 +1,5 @@
"""Tests for AVM Fritz!Box sensor component.""" """Tests for AVM Fritz!Box sensor component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@ -21,6 +20,7 @@ import homeassistant.util.dt as dt_util
from . import MOCK_CONFIG, FritzDeviceSensorMock from . import MOCK_CONFIG, FritzDeviceSensorMock
from tests.async_mock import Mock
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
ENTITY_ID = f"{DOMAIN}.fake_name" ENTITY_ID = f"{DOMAIN}.fake_name"

View file

@ -1,6 +1,5 @@
"""Tests for AVM Fritz!Box switch component.""" """Tests for AVM Fritz!Box switch component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import Mock
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@ -29,6 +28,7 @@ import homeassistant.util.dt as dt_util
from . import MOCK_CONFIG, FritzDeviceSwitchMock from . import MOCK_CONFIG, FritzDeviceSwitchMock
from tests.async_mock import Mock
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
ENTITY_ID = f"{DOMAIN}.fake_name" ENTITY_ID = f"{DOMAIN}.fake_name"

View file

@ -1,6 +1,4 @@
"""Test the Garmin Connect config flow.""" """Test the Garmin Connect config flow."""
from unittest.mock import patch
from garminconnect import ( from garminconnect import (
GarminConnectAuthenticationError, GarminConnectAuthenticationError,
GarminConnectConnectionError, GarminConnectConnectionError,
@ -12,6 +10,7 @@ from homeassistant import data_entry_flow
from homeassistant.components.garmin_connect.const import DOMAIN from homeassistant.components.garmin_connect.const import DOMAIN
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from tests.async_mock import patch
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
MOCK_CONF = { MOCK_CONF = {

View file

@ -1,5 +1,5 @@
"""Tests for the GDACS component.""" """Tests for the GDACS component."""
from unittest.mock import MagicMock from tests.async_mock import MagicMock
def _generate_mock_feed_entry( def _generate_mock_feed_entry(

View file

@ -1,7 +1,6 @@
"""The test for the geo rss events sensor platform.""" """The test for the geo rss events sensor platform."""
import unittest import unittest
from unittest import mock from unittest import mock
from unittest.mock import MagicMock, patch
from homeassistant.components import sensor from homeassistant.components import sensor
import homeassistant.components.geo_rss_events.sensor as geo_rss_events import homeassistant.components.geo_rss_events.sensor as geo_rss_events
@ -14,6 +13,7 @@ from homeassistant.const import (
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import MagicMock, patch
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
fire_time_changed, fire_time_changed,

View file

@ -1,7 +1,4 @@
"""The tests for the Geofency device tracker platform.""" """The tests for the Geofency device tracker platform."""
# pylint: disable=redefined-outer-name
from unittest.mock import Mock, patch
import pytest import pytest
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
@ -16,6 +13,9 @@ from homeassistant.const import (
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import slugify from homeassistant.util import slugify
# pylint: disable=redefined-outer-name
from tests.async_mock import Mock, patch
HOME_LATITUDE = 37.239622 HOME_LATITUDE = 37.239622
HOME_LONGITUDE = -115.815811 HOME_LONGITUDE = -115.815811

View file

@ -1,5 +1,5 @@
"""Tests for the geonetnz_quakes component.""" """Tests for the geonetnz_quakes component."""
from unittest.mock import MagicMock from tests.async_mock import MagicMock
def _generate_mock_feed_entry( def _generate_mock_feed_entry(

View file

@ -1,5 +1,5 @@
"""The tests for the GeoNet NZ Volcano Feed integration.""" """The tests for the GeoNet NZ Volcano Feed integration."""
from unittest.mock import MagicMock from tests.async_mock import MagicMock
def _generate_mock_feed_entry( def _generate_mock_feed_entry(

View file

@ -1,8 +1,8 @@
"""Test configuration and mocks for the google integration.""" """Test configuration and mocks for the google integration."""
from unittest.mock import patch
import pytest import pytest
from tests.async_mock import patch
TEST_CALENDAR = { TEST_CALENDAR = {
"id": "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com", "id": "qwertyuiopasdfghjklzxcvbnm@import.calendar.google.com",
"etag": '"3584134138943410"', "etag": '"3584134138943410"',

View file

@ -1,6 +1,5 @@
"""The tests for the google calendar platform.""" """The tests for the google calendar platform."""
import copy import copy
from unittest.mock import Mock, patch
import httplib2 import httplib2
import pytest import pytest
@ -23,6 +22,7 @@ from homeassistant.setup import async_setup_component
from homeassistant.util import slugify from homeassistant.util import slugify
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from tests.async_mock import Mock, patch
from tests.common import async_mock_service from tests.common import async_mock_service
GOOGLE_CONFIG = {CONF_CLIENT_ID: "client_id", CONF_CLIENT_SECRET: "client_secret"} GOOGLE_CONFIG = {CONF_CLIENT_ID: "client_id", CONF_CLIENT_SECRET: "client_secret"}

View file

@ -1,11 +1,11 @@
"""The tests for the Google Calendar component.""" """The tests for the Google Calendar component."""
from unittest.mock import patch
import pytest import pytest
import homeassistant.components.google as google import homeassistant.components.google as google
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import patch
@pytest.fixture(name="google_setup") @pytest.fixture(name="google_setup")
def mock_google_setup(hass): def mock_google_setup(hass):

View file

@ -1,6 +1,5 @@
"""Tests for the Google Assistant traits.""" """Tests for the Google Assistant traits."""
import logging import logging
from unittest.mock import Mock
import pytest import pytest
@ -45,7 +44,7 @@ from homeassistant.util import color
from . import BASIC_CONFIG, MockConfig from . import BASIC_CONFIG, MockConfig
from tests.async_mock import patch from tests.async_mock import Mock, patch
from tests.common import async_mock_service from tests.common import async_mock_service
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -2,7 +2,6 @@
import asyncio import asyncio
import os import os
import shutil import shutil
from unittest.mock import patch
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
ATTR_MEDIA_CONTENT_ID, ATTR_MEDIA_CONTENT_ID,
@ -12,6 +11,7 @@ from homeassistant.components.media_player.const import (
import homeassistant.components.tts as tts import homeassistant.components.tts as tts
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import assert_setup_component, get_test_home_assistant, mock_service from tests.common import assert_setup_component, get_test_home_assistant, mock_service
from tests.components.tts.test_init import mutagen_mock # noqa: F401 from tests.components.tts.test_init import mutagen_mock # noqa: F401

View file

@ -1,7 +1,6 @@
"""The tests for the Google Wifi platform.""" """The tests for the Google Wifi platform."""
from datetime import datetime, timedelta from datetime import datetime, timedelta
import unittest import unittest
from unittest.mock import Mock, patch
import requests_mock import requests_mock
@ -11,6 +10,7 @@ from homeassistant.const import STATE_UNKNOWN
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from tests.async_mock import Mock, patch
from tests.common import assert_setup_component, get_test_home_assistant from tests.common import assert_setup_component, get_test_home_assistant
NAME = "foo" NAME = "foo"

View file

@ -1,6 +1,4 @@
"""The tests the for GPSLogger device tracker platform.""" """The tests the for GPSLogger device tracker platform."""
from unittest.mock import Mock, patch
import pytest import pytest
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
@ -16,6 +14,8 @@ from homeassistant.const import (
from homeassistant.helpers.dispatcher import DATA_DISPATCHER from homeassistant.helpers.dispatcher import DATA_DISPATCHER
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.async_mock import Mock, patch
HOME_LATITUDE = 37.239622 HOME_LATITUDE = 37.239622
HOME_LONGITUDE = -115.815811 HOME_LONGITUDE = -115.815811

View file

@ -2,7 +2,6 @@
import socket import socket
import unittest import unittest
from unittest import mock from unittest import mock
from unittest.mock import patch
import homeassistant.components.graphite as graphite import homeassistant.components.graphite as graphite
from homeassistant.const import ( from homeassistant.const import (
@ -15,6 +14,7 @@ from homeassistant.const import (
import homeassistant.core as ha import homeassistant.core as ha
from homeassistant.setup import setup_component from homeassistant.setup import setup_component
from tests.async_mock import patch
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant

Some files were not shown because too many files have changed in this diff Show more