Use builtin mock (#36473)
This commit is contained in:
parent
874c8fea03
commit
4170eb0f83
6 changed files with 13 additions and 13 deletions
|
@ -1,12 +1,13 @@
|
|||
"""Fixtures for tests."""
|
||||
|
||||
from mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .common import ComponentFactory
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def component_factory(hass: HomeAssistant):
|
||||
|
|
|
@ -4,8 +4,6 @@ import os
|
|||
import shutil
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from mock import Mock, patch
|
||||
|
||||
from homeassistant.components.media_player.const import (
|
||||
ATTR_MEDIA_CONTENT_ID,
|
||||
DOMAIN as DOMAIN_MP,
|
||||
|
@ -16,6 +14,7 @@ from homeassistant.config import async_process_ha_core_config
|
|||
from homeassistant.const import HTTP_INTERNAL_SERVER_ERROR
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.async_mock import Mock, patch
|
||||
from tests.common import assert_setup_component, get_test_home_assistant, mock_service
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import datetime
|
||||
from typing import Union
|
||||
|
||||
import mock
|
||||
from py17track.package import Package
|
||||
import pytest
|
||||
|
||||
|
@ -14,6 +13,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
|||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import utcnow
|
||||
|
||||
from tests.async_mock import MagicMock, patch
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
VALID_CONFIG_MINIMAL = {
|
||||
|
@ -113,7 +113,7 @@ class ProfileMock:
|
|||
@pytest.fixture(autouse=True, name="mock_client")
|
||||
def fixture_mock_client():
|
||||
"""Mock py17track client."""
|
||||
with mock.patch(
|
||||
with patch(
|
||||
"homeassistant.components.seventeentrack.sensor.SeventeenTrackClient",
|
||||
new=ClientMock,
|
||||
):
|
||||
|
@ -137,7 +137,7 @@ async def _goto_future(hass, future=None):
|
|||
"""Move to future."""
|
||||
if not future:
|
||||
future = utcnow() + datetime.timedelta(minutes=10)
|
||||
with mock.patch("homeassistant.util.utcnow", return_value=future):
|
||||
with patch("homeassistant.util.utcnow", return_value=future):
|
||||
async_fire_time_changed(hass, future)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -245,7 +245,7 @@ async def test_delivered_not_shown(hass):
|
|||
)
|
||||
ProfileMock.package_list = [package]
|
||||
|
||||
hass.components.persistent_notification = mock.MagicMock()
|
||||
hass.components.persistent_notification = MagicMock()
|
||||
await _setup_seventeentrack(hass, VALID_CONFIG_FULL_NO_DELIVERED)
|
||||
assert not hass.states.async_entity_ids()
|
||||
hass.components.persistent_notification.create.assert_called()
|
||||
|
@ -258,7 +258,7 @@ async def test_delivered_shown(hass):
|
|||
)
|
||||
ProfileMock.package_list = [package]
|
||||
|
||||
hass.components.persistent_notification = mock.MagicMock()
|
||||
hass.components.persistent_notification = MagicMock()
|
||||
await _setup_seventeentrack(hass, VALID_CONFIG_FULL)
|
||||
|
||||
assert hass.states.get("sensor.seventeentrack_package_456") is not None
|
||||
|
@ -283,7 +283,7 @@ async def test_becomes_delivered_not_shown_notification(hass):
|
|||
)
|
||||
ProfileMock.package_list = [package_delivered]
|
||||
|
||||
hass.components.persistent_notification = mock.MagicMock()
|
||||
hass.components.persistent_notification = MagicMock()
|
||||
await _goto_future(hass)
|
||||
|
||||
hass.components.persistent_notification.create.assert_called()
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
from typing import Callable, Dict, NamedTuple, Tuple
|
||||
|
||||
from mock import MagicMock
|
||||
import pyvera as pv
|
||||
|
||||
from homeassistant.components.vera.const import CONF_CONTROLLER, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import MagicMock
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
SetupCallback = Callable[[pv.VeraController, dict], None]
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
"""Fixtures for tests."""
|
||||
|
||||
from mock import patch
|
||||
import pytest
|
||||
|
||||
from .common import ComponentFactory
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def vera_component_factory():
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""Vera tests."""
|
||||
from mock import patch
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
|
@ -12,7 +11,7 @@ from homeassistant.data_entry_flow import (
|
|||
RESULT_TYPE_FORM,
|
||||
)
|
||||
|
||||
from tests.async_mock import MagicMock
|
||||
from tests.async_mock import MagicMock, patch
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue