Prevent 3rd party lib from opening sockets in broadlink tests (#55593)
This commit is contained in:
parent
d4a2b36638
commit
cabb9c0ea4
2 changed files with 17 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import broadlink.exceptions as blke
|
import broadlink.exceptions as blke
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.broadlink.const import DOMAIN
|
from homeassistant.components.broadlink.const import DOMAIN
|
||||||
from homeassistant.components.broadlink.device import get_domains
|
from homeassistant.components.broadlink.device import get_domains
|
||||||
|
@ -15,6 +16,13 @@ from tests.common import mock_device_registry, mock_registry
|
||||||
DEVICE_FACTORY = "homeassistant.components.broadlink.device.blk.gendevice"
|
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):
|
async def test_device_setup(hass):
|
||||||
"""Test a successful setup."""
|
"""Test a successful setup."""
|
||||||
device = get_device("Office")
|
device = get_device("Office")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Tests for Broadlink heartbeats."""
|
"""Tests for Broadlink heartbeats."""
|
||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.broadlink.heartbeat import BroadlinkHeartbeat
|
from homeassistant.components.broadlink.heartbeat import BroadlinkHeartbeat
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
|
|
||||||
|
@ -11,6 +13,13 @@ from tests.common import async_fire_time_changed
|
||||||
DEVICE_PING = "homeassistant.components.broadlink.heartbeat.blk.ping"
|
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):
|
async def test_heartbeat_trigger_startup(hass):
|
||||||
"""Test that the heartbeat is initialized with the first config entry."""
|
"""Test that the heartbeat is initialized with the first config entry."""
|
||||||
device = get_device("Office")
|
device = get_device("Office")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue