Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion tests/auth/mfa_modules/test_notify.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Test the HMAC-based One Time Password (MFA) auth module."""
import asyncio
from unittest.mock import patch

from homeassistant import data_entry_flow
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.components.notify import NOTIFY_SERVICE_SCHEMA

from tests.async_mock import patch
from tests.common import MockUser, async_mock_service

MOCK_CODE = "123456"
Expand Down
2 changes: 1 addition & 1 deletion tests/auth/mfa_modules/test_totp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Test the Time-based One Time Password (MFA) auth module."""
import asyncio
from unittest.mock import patch

from homeassistant import data_entry_flow
from homeassistant.auth import auth_manager_from_config, models as auth_models
from homeassistant.auth.mfa_modules import auth_mfa_module_from_config

from tests.async_mock import patch
from tests.common import MockUser

MOCK_CODE = "123456"
Expand Down
2 changes: 1 addition & 1 deletion tests/auth/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests for the Home Assistant auth module."""
from datetime import timedelta
from unittest.mock import Mock, patch

import jwt
import pytest
Expand All @@ -12,6 +11,7 @@
from homeassistant.core import callback
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


Expand Down
3 changes: 1 addition & 2 deletions tests/components/abode/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Common methods used across tests for Abode."""
from unittest.mock import patch

from homeassistant.components.abode import DOMAIN as ABODE_DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.setup import async_setup_component

from tests.async_mock import patch
from tests.common import MockConfigEntry


Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_alarm_control_panel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode alarm control panel device."""
from unittest.mock import PropertyMock, patch

import abodepy.helpers.constants as CONST

from homeassistant.components.abode import ATTR_DEVICE_ID
Expand All @@ -19,6 +17,8 @@

from .common import setup_platform

from tests.async_mock import PropertyMock, patch

DEVICE_ID = "alarm_control_panel.abode_alarm"


Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_camera.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Tests for the Abode camera device."""
from unittest.mock import patch

from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, STATE_IDLE

from .common import setup_platform

from tests.async_mock import patch


async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
Expand Down
3 changes: 1 addition & 2 deletions tests/components/abode/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Tests for the Abode config flow."""
from unittest.mock import patch

from abodepy.exceptions import AbodeAuthenticationException

from homeassistant import data_entry_flow
from homeassistant.components.abode import config_flow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, HTTP_INTERNAL_SERVER_ERROR

from tests.async_mock import patch
from tests.common import MockConfigEntry

CONF_POLLING = "polling"
Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_cover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode cover device."""
from unittest.mock import patch

from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.cover import DOMAIN as COVER_DOMAIN
from homeassistant.const import (
Expand All @@ -13,6 +11,8 @@

from .common import setup_platform

from tests.async_mock import patch

DEVICE_ID = "cover.garage_door"


Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode module."""
from unittest.mock import patch

from homeassistant.components.abode import (
DOMAIN as ABODE_DOMAIN,
SERVICE_CAPTURE_IMAGE,
Expand All @@ -11,6 +9,8 @@

from .common import setup_platform

from tests.async_mock import patch


async def test_change_settings(hass):
"""Test change_setting service."""
Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_light.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode light device."""
from unittest.mock import patch

from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
Expand All @@ -19,6 +17,8 @@

from .common import setup_platform

from tests.async_mock import patch

DEVICE_ID = "light.living_room_lamp"


Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_lock.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode lock device."""
from unittest.mock import patch

from homeassistant.components.abode import ATTR_DEVICE_ID
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.const import (
Expand All @@ -13,6 +11,8 @@

from .common import setup_platform

from tests.async_mock import patch

DEVICE_ID = "lock.test_lock"


Expand Down
4 changes: 2 additions & 2 deletions tests/components/abode/test_switch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the Abode switch device."""
from unittest.mock import patch

from homeassistant.components.abode import (
DOMAIN as ABODE_DOMAIN,
SERVICE_TRIGGER_AUTOMATION,
Expand All @@ -16,6 +14,8 @@

from .common import setup_platform

from tests.async_mock import patch

AUTOMATION_ID = "switch.test_automation"
AUTOMATION_UID = "47fae27488f74f55b964a81a066c3a01"
DEVICE_ID = "switch.test_switch"
Expand Down
2 changes: 1 addition & 1 deletion tests/components/androidtv/patchers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Define patches used for androidtv tests."""

from unittest.mock import mock_open, patch
from tests.async_mock import mock_open, patch


class AdbDeviceTcpFake:
Expand Down
3 changes: 2 additions & 1 deletion tests/components/androidtv/test_media_player.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""The tests for the androidtv platform."""
import base64
import logging
from unittest.mock import patch

from androidtv.exceptions import LockNotAcquiredException

Expand Down Expand Up @@ -41,6 +40,8 @@

from . import patchers

from tests.async_mock import patch

# Android TV device with Python ADB implementation
CONFIG_ANDROIDTV_PYTHON_ADB = {
DOMAIN: {
Expand Down
2 changes: 1 addition & 1 deletion tests/components/api/test_init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""The tests for the Home Assistant API component."""
# pylint: disable=protected-access
import json
from unittest.mock import patch

from aiohttp import web
import pytest
Expand All @@ -12,6 +11,7 @@
import homeassistant.core as ha
from homeassistant.setup import async_setup_component

from tests.async_mock import patch
from tests.common import async_mock_service


Expand Down
2 changes: 1 addition & 1 deletion tests/components/apns/test_notify.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""The tests for the APNS component."""
import io
import unittest
from unittest.mock import Mock, mock_open, patch

from apns2.errors import Unregistered
import yaml
Expand All @@ -11,6 +10,7 @@
from homeassistant.core import State
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

CONFIG = {
Expand Down
4 changes: 2 additions & 2 deletions tests/components/apprise/test_notify.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""The tests for the apprise notification platform."""
from unittest.mock import MagicMock, patch

from homeassistant.setup import async_setup_component

from tests.async_mock import MagicMock, patch

BASE_COMPONENT = "notify"


Expand Down
3 changes: 1 addition & 2 deletions tests/components/aprs/test_device_tracker.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Test APRS device tracker."""
from unittest.mock import Mock, patch

import aprslib

import homeassistant.components.aprs.device_tracker as device_tracker
from homeassistant.const import EVENT_HOMEASSISTANT_START

from tests.async_mock import Mock, patch
from tests.common import get_test_home_assistant

DEFAULT_PORT = 14580
Expand Down
5 changes: 3 additions & 2 deletions tests/components/arlo/test_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The tests for the Netgear Arlo sensors."""
from collections import namedtuple
from unittest.mock import MagicMock, patch

import pytest

Expand All @@ -12,6 +11,8 @@
UNIT_PERCENTAGE,
)

from tests.async_mock import patch


def _get_named_tuple(input_dict):
return namedtuple("Struct", input_dict.keys())(*input_dict.values())
Expand Down Expand Up @@ -94,7 +95,7 @@ def sensor_with_hass_data(default_sensor, hass):
def mock_dispatch():
"""Mock the dispatcher connect method."""
target = "homeassistant.components.arlo.sensor.async_dispatcher_connect"
with patch(target, MagicMock()) as _mock:
with patch(target) as _mock:
yield _mock


Expand Down
4 changes: 1 addition & 3 deletions tests/components/atag/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Tests for the Atag config flow."""
from unittest.mock import PropertyMock

from pyatag import AtagException

from homeassistant import config_entries, data_entry_flow
from homeassistant.components.atag import DOMAIN
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

FIXTURE_USER_INPUT = {
Expand Down
4 changes: 1 addition & 3 deletions tests/components/august/test_gateway.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""The gateway tests for the august platform."""
from unittest.mock import MagicMock

from homeassistant.components.august.const import DOMAIN
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


Expand Down
2 changes: 1 addition & 1 deletion tests/components/auth/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Integration tests for the auth component."""
from datetime import timedelta
from unittest.mock import patch

from homeassistant.auth.models import Credentials
from homeassistant.components import auth
Expand All @@ -10,6 +9,7 @@

from . import async_setup_auth

from tests.async_mock import patch
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI, MockUser


Expand Down
3 changes: 1 addition & 2 deletions tests/components/auth/test_login_flow.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Tests for the login flow."""
from unittest.mock import patch

from . import async_setup_auth

from tests.async_mock import patch
from tests.common import CLIENT_ID, CLIENT_REDIRECT_URI


Expand Down
4 changes: 1 addition & 3 deletions tests/components/automation/test_homeassistant.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""The tests for the Event automation."""
from unittest.mock import patch

import homeassistant.components.automation as automation
from homeassistant.core import CoreState
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


Expand Down
2 changes: 1 addition & 1 deletion tests/components/automation/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The tests for the automation component."""
from datetime import timedelta
from unittest.mock import Mock, patch

import pytest

Expand All @@ -19,6 +18,7 @@
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util

from tests.async_mock import Mock, patch
from tests.common import (
assert_setup_component,
async_fire_time_changed,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/automation/test_numeric_state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The tests for numeric state automation."""
from datetime import timedelta
from unittest.mock import patch

import pytest
import voluptuous as vol
Expand All @@ -11,6 +10,7 @@
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util

from tests.async_mock import patch
from tests.common import (
assert_setup_component,
async_fire_time_changed,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/automation/test_state.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The test for state automation."""
from datetime import timedelta
from unittest.mock import patch

import pytest

Expand All @@ -9,6 +8,7 @@
from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util

from tests.async_mock import patch
from tests.common import (
assert_setup_component,
async_fire_time_changed,
Expand Down
Loading