mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 14:00:24 +00:00
Fix lifx tests opening sockets (#156460)
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
"""Tests for the lifx integration config flow."""
|
"""Tests for the lifx integration config flow."""
|
||||||
|
|
||||||
|
from collections.abc import Generator
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
import socket
|
import socket
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -44,6 +45,15 @@ from . import (
|
|||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
|
"""Override async_setup_entry."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.lifx.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery(hass: HomeAssistant) -> None:
|
async def test_discovery(hass: HomeAssistant) -> None:
|
||||||
"""Test setting up discovery."""
|
"""Test setting up discovery."""
|
||||||
with _patch_discovery(), _patch_config_flow_try_connect():
|
with _patch_discovery(), _patch_config_flow_try_connect():
|
||||||
@@ -591,6 +601,7 @@ async def test_refuse_relays(hass: HomeAssistant) -> None:
|
|||||||
assert result2["errors"] == {"base": "cannot_connect"}
|
assert result2["errors"] == {"base": "cannot_connect"}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("mock_setup_entry", [None]) # Disable the autouse fixture
|
||||||
async def test_suggested_area(
|
async def test_suggested_area(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
area_registry: ar.AreaRegistry,
|
area_registry: ar.AreaRegistry,
|
||||||
|
|||||||
@@ -1619,6 +1619,7 @@ async def test_transitions_brightness_only(hass: HomeAssistant) -> None:
|
|||||||
bulb.get_color.reset_mock()
|
bulb.get_color.reset_mock()
|
||||||
|
|
||||||
# Ensure we force an update after the transition
|
# Ensure we force an update after the transition
|
||||||
|
with _patch_discovery(device=bulb):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(bulb.get_color.calls) == 2
|
assert len(bulb.get_color.calls) == 2
|
||||||
@@ -1714,6 +1715,7 @@ async def test_transitions_color_bulb(hass: HomeAssistant) -> None:
|
|||||||
bulb.get_color.reset_mock()
|
bulb.get_color.reset_mock()
|
||||||
|
|
||||||
# Ensure we force an update after the transition
|
# Ensure we force an update after the transition
|
||||||
|
with _patch_discovery(device=bulb):
|
||||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=5))
|
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=5))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(bulb.get_color.calls) == 2
|
assert len(bulb.get_color.calls) == 2
|
||||||
|
|||||||
Reference in New Issue
Block a user