Skip to content

Commit

Permalink
Use builtin mock (home-assistant#36473)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jun 5, 2020
1 parent 874c8fe commit 4170eb0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion tests/components/gogogate2/conftest.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 1 addition & 2 deletions tests/components/marytts/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
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,
Expand All @@ -16,6 +14,7 @@
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


Expand Down
12 changes: 6 additions & 6 deletions tests/components/seventeentrack/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
from typing import Union

import mock
from py17track.package import Package
import pytest

Expand All @@ -14,6 +13,7 @@
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 = {
Expand Down Expand Up @@ -113,7 +113,7 @@ async def summary(self, show_archived: bool = False) -> dict:
@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,
):
Expand All @@ -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()

Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/components/vera/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion tests/components/vera/conftest.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down
3 changes: 1 addition & 2 deletions tests/components/vera/test_config_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Vera tests."""
from mock import patch
from requests.exceptions import RequestException

from homeassistant import config_entries, data_entry_flow
Expand All @@ -12,7 +11,7 @@
RESULT_TYPE_FORM,
)

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


Expand Down

0 comments on commit 4170eb0

Please sign in to comment.