Prevent 3rd party lib from opening sockets in broadlink tests (#55636)

pull/55628/head
Erik Montnemery 2021-09-03 10:13:35 +02:00 committed by GitHub
parent 0c2772e0be
commit 4684ea2d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 17 deletions

View File

@ -0,0 +1,11 @@
"""Broadlink test helpers."""
from unittest.mock import patch
import pytest
@pytest.fixture(autouse=True)
def mock_heartbeat():
"""Mock broadlink heartbeat."""
with patch("homeassistant.components.broadlink.heartbeat.blk.ping"):
yield

View File

@ -2,7 +2,6 @@
from unittest.mock import patch
import broadlink.exceptions as blke
import pytest
from homeassistant.components.broadlink.const import DOMAIN
from homeassistant.components.broadlink.device import get_domains
@ -16,13 +15,6 @@ from tests.common import mock_device_registry, mock_registry
DEVICE_FACTORY = "homeassistant.components.broadlink.device.blk.gendevice"
@pytest.fixture(autouse=True)
def mock_heartbeat():
"""Mock broadlink heartbeat."""
with patch("homeassistant.components.broadlink.heartbeat.blk.ping"):
yield
async def test_device_setup(hass):
"""Test a successful setup."""
device = get_device("Office")

View File

@ -1,8 +1,6 @@
"""Tests for Broadlink heartbeats."""
from unittest.mock import call, patch
import pytest
from homeassistant.components.broadlink.heartbeat import BroadlinkHeartbeat
from homeassistant.util import dt
@ -13,13 +11,6 @@ from tests.common import async_fire_time_changed
DEVICE_PING = "homeassistant.components.broadlink.heartbeat.blk.ping"
@pytest.fixture(autouse=True)
def mock_heartbeat():
"""Mock broadlink heartbeat."""
with patch("homeassistant.components.broadlink.heartbeat.blk.ping"):
yield
async def test_heartbeat_trigger_startup(hass):
"""Test that the heartbeat is initialized with the first config entry."""
device = get_device("Office")