mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Improve type hints in hue tests (#121298)
This commit is contained in:
parent
7332bc5faf
commit
b9cfd4e8ce
@ -2,7 +2,7 @@
|
||||
|
||||
import asyncio
|
||||
from collections import deque
|
||||
import json
|
||||
from collections.abc import Generator
|
||||
import logging
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
@ -16,21 +16,24 @@ from homeassistant.components import hue
|
||||
from homeassistant.components.hue.v1 import sensor_base as hue_sensor_base
|
||||
from homeassistant.components.hue.v2.device import async_setup_devices
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
from tests.common import MockConfigEntry, load_json_array_fixture
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_request_delay():
|
||||
def no_request_delay() -> Generator[None]:
|
||||
"""Make the request refresh delay 0 for instant tests."""
|
||||
with patch("homeassistant.components.hue.const.REQUEST_REFRESH_DELAY", 0):
|
||||
yield
|
||||
|
||||
|
||||
def create_mock_bridge(hass, api_version=1):
|
||||
def create_mock_bridge(hass: HomeAssistant, api_version: int = 1) -> Mock:
|
||||
"""Create a mocked HueBridge instance."""
|
||||
bridge = Mock(
|
||||
hass=hass,
|
||||
@ -44,10 +47,10 @@ def create_mock_bridge(hass, api_version=1):
|
||||
bridge.logger = logging.getLogger(__name__)
|
||||
|
||||
if bridge.api_version == 2:
|
||||
bridge.api = create_mock_api_v2(hass)
|
||||
bridge.api = create_mock_api_v2()
|
||||
bridge.mock_requests = bridge.api.mock_requests
|
||||
else:
|
||||
bridge.api = create_mock_api_v1(hass)
|
||||
bridge.api = create_mock_api_v1()
|
||||
bridge.sensor_manager = hue_sensor_base.SensorManager(bridge)
|
||||
bridge.mock_requests = bridge.api.mock_requests
|
||||
bridge.mock_light_responses = bridge.api.mock_light_responses
|
||||
@ -79,18 +82,18 @@ def create_mock_bridge(hass, api_version=1):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_api_v1(hass):
|
||||
def mock_api_v1() -> Mock:
|
||||
"""Mock the Hue V1 api."""
|
||||
return create_mock_api_v1(hass)
|
||||
return create_mock_api_v1()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_api_v2(hass):
|
||||
def mock_api_v2() -> Mock:
|
||||
"""Mock the Hue V2 api."""
|
||||
return create_mock_api_v2(hass)
|
||||
return create_mock_api_v2()
|
||||
|
||||
|
||||
def create_mock_api_v1(hass):
|
||||
def create_mock_api_v1() -> Mock:
|
||||
"""Create a mock V1 API."""
|
||||
api = Mock(spec=aiohue_v1.HueBridgeV1)
|
||||
api.initialize = AsyncMock()
|
||||
@ -134,12 +137,12 @@ def create_mock_api_v1(hass):
|
||||
|
||||
|
||||
@pytest.fixture(scope="package")
|
||||
def v2_resources_test_data():
|
||||
def v2_resources_test_data() -> JsonArrayType:
|
||||
"""Load V2 resources mock data."""
|
||||
return json.loads(load_fixture("hue/v2_resources.json"))
|
||||
return load_json_array_fixture("hue/v2_resources.json")
|
||||
|
||||
|
||||
def create_mock_api_v2(hass):
|
||||
def create_mock_api_v2() -> Mock:
|
||||
"""Create a mock V2 API."""
|
||||
api = Mock(spec=aiohue_v2.HueBridgeV2)
|
||||
api.initialize = AsyncMock()
|
||||
@ -192,30 +195,32 @@ def create_mock_api_v2(hass):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_bridge_v1(hass):
|
||||
def mock_bridge_v1(hass: HomeAssistant) -> Mock:
|
||||
"""Mock a Hue bridge with V1 api."""
|
||||
return create_mock_bridge(hass, api_version=1)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_bridge_v2(hass):
|
||||
def mock_bridge_v2(hass: HomeAssistant) -> Mock:
|
||||
"""Mock a Hue bridge with V2 api."""
|
||||
return create_mock_bridge(hass, api_version=2)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry_v1(hass):
|
||||
def mock_config_entry_v1() -> MockConfigEntry:
|
||||
"""Mock a config entry for a Hue V1 bridge."""
|
||||
return create_config_entry(api_version=1)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry_v2(hass):
|
||||
def mock_config_entry_v2() -> MockConfigEntry:
|
||||
"""Mock a config entry."""
|
||||
return create_config_entry(api_version=2)
|
||||
|
||||
|
||||
def create_config_entry(api_version=1, host="mock-host"):
|
||||
def create_config_entry(
|
||||
api_version: int = 1, host: str = "mock-host"
|
||||
) -> MockConfigEntry:
|
||||
"""Mock a config entry for a Hue bridge."""
|
||||
return MockConfigEntry(
|
||||
domain=hue.DOMAIN,
|
||||
@ -224,7 +229,7 @@ def create_config_entry(api_version=1, host="mock-host"):
|
||||
)
|
||||
|
||||
|
||||
async def setup_component(hass):
|
||||
async def setup_component(hass: HomeAssistant) -> None:
|
||||
"""Mock setup Hue component."""
|
||||
with patch.object(hue, "async_setup_entry", return_value=True):
|
||||
assert (
|
||||
@ -237,7 +242,9 @@ async def setup_component(hass):
|
||||
)
|
||||
|
||||
|
||||
async def setup_bridge(hass, mock_bridge, config_entry):
|
||||
async def setup_bridge(
|
||||
hass: HomeAssistant, mock_bridge: Mock, config_entry: MockConfigEntry
|
||||
) -> None:
|
||||
"""Load the Hue integration with the provided bridge."""
|
||||
mock_bridge.config_entry = config_entry
|
||||
with patch.object(
|
||||
@ -249,11 +256,11 @@ async def setup_bridge(hass, mock_bridge, config_entry):
|
||||
|
||||
|
||||
async def setup_platform(
|
||||
hass,
|
||||
mock_bridge,
|
||||
platforms,
|
||||
hostname=None,
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
mock_bridge: Mock,
|
||||
platforms: list[Platform] | tuple[Platform] | Platform,
|
||||
hostname: str | None = None,
|
||||
) -> None:
|
||||
"""Load the Hue integration with the provided bridge for given platform(s)."""
|
||||
if not isinstance(platforms, (list, tuple)):
|
||||
platforms = [platforms]
|
||||
|
@ -1,13 +1,16 @@
|
||||
"""Philips Hue binary_sensor platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
from .const import FAKE_BINARY_SENSOR, FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY
|
||||
|
||||
|
||||
async def test_binary_sensors(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test if all v2 binary_sensors get created with correct features."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -78,7 +81,9 @@ async def test_binary_sensors(
|
||||
assert sensor.attributes["device_class"] == "motion"
|
||||
|
||||
|
||||
async def test_binary_sensor_add_update(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
async def test_binary_sensor_add_update(
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock
|
||||
) -> None:
|
||||
"""Test if binary_sensor get added/updated from events."""
|
||||
await mock_bridge_v2.api.load_test_data([FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY])
|
||||
await setup_platform(hass, mock_bridge_v2, "binary_sensor")
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Test Hue bridge."""
|
||||
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from aiohttp import client_exceptions
|
||||
from aiohue.errors import Unauthorized
|
||||
@ -21,7 +21,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_bridge_setup_v1(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
async def test_bridge_setup_v1(hass: HomeAssistant, mock_api_v1: Mock) -> None:
|
||||
"""Test a successful setup for V1 bridge."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
@ -45,7 +45,7 @@ async def test_bridge_setup_v1(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
assert forward_entries == {"light", "binary_sensor", "sensor"}
|
||||
|
||||
|
||||
async def test_bridge_setup_v2(hass: HomeAssistant, mock_api_v2) -> None:
|
||||
async def test_bridge_setup_v2(hass: HomeAssistant, mock_api_v2: Mock) -> None:
|
||||
"""Test a successful setup for V2 bridge."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
@ -113,7 +113,9 @@ async def test_bridge_setup_timeout(hass: HomeAssistant) -> None:
|
||||
await hue_bridge.async_initialize_bridge()
|
||||
|
||||
|
||||
async def test_reset_unloads_entry_if_setup(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
async def test_reset_unloads_entry_if_setup(
|
||||
hass: HomeAssistant, mock_api_v1: Mock
|
||||
) -> None:
|
||||
"""Test calling reset while the entry has been setup."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
@ -143,7 +145,7 @@ async def test_reset_unloads_entry_if_setup(hass: HomeAssistant, mock_api_v1) ->
|
||||
assert len(hass.services.async_services()) == 0
|
||||
|
||||
|
||||
async def test_handle_unauthorized(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
async def test_handle_unauthorized(hass: HomeAssistant, mock_api_v1: Mock) -> None:
|
||||
"""Test handling an unauthorized error on update."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""The tests for Philips Hue device triggers for V1 bridge."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from pytest_unordered import unordered
|
||||
|
||||
from homeassistant.components import automation, hue
|
||||
@ -20,7 +22,7 @@ REMOTES_RESPONSE = {"7": HUE_TAP_REMOTE_1, "8": HUE_DIMMER_REMOTE_1}
|
||||
async def test_get_triggers(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v1: Mock,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test we get the expected triggers from a hue remote."""
|
||||
@ -90,7 +92,7 @@ async def test_get_triggers(
|
||||
|
||||
async def test_if_fires_on_state_change(
|
||||
hass: HomeAssistant,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v1: Mock,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
service_calls: list[ServiceCall],
|
||||
) -> None:
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""The tests for Philips Hue device triggers for V2 bridge."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from aiohue.v2.models.button import ButtonEvent
|
||||
from pytest_unordered import unordered
|
||||
|
||||
@ -9,6 +11,7 @@ from homeassistant.components.hue.v2.device import async_setup_devices
|
||||
from homeassistant.components.hue.v2.hue_event import async_setup_hue_events
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
|
||||
@ -16,7 +19,7 @@ from tests.common import async_capture_events, async_get_device_automations
|
||||
|
||||
|
||||
async def test_hue_event(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test hue button events."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -48,8 +51,8 @@ async def test_hue_event(
|
||||
async def test_get_triggers(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test we get the expected triggers from a hue remote."""
|
||||
|
@ -1,5 +1,7 @@
|
||||
"""Test Hue diagnostics."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import setup_platform
|
||||
@ -9,7 +11,7 @@ from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics_v1(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator, mock_bridge_v1
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test diagnostics v1."""
|
||||
await setup_platform(hass, mock_bridge_v1, [])
|
||||
@ -19,7 +21,7 @@ async def test_diagnostics_v1(
|
||||
|
||||
|
||||
async def test_diagnostics_v2(
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator, mock_bridge_v2
|
||||
hass: HomeAssistant, hass_client: ClientSessionGenerator, mock_bridge_v2: Mock
|
||||
) -> None:
|
||||
"""Test diagnostics v2."""
|
||||
mock_bridge_v2.api.get_diagnostics.return_value = {"hello": "world"}
|
||||
|
@ -1,14 +1,17 @@
|
||||
"""Philips Hue Event platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.components.event import ATTR_EVENT_TYPE, ATTR_EVENT_TYPES
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
from .const import FAKE_DEVICE, FAKE_ROTARY, FAKE_ZIGBEE_CONNECTIVITY
|
||||
|
||||
|
||||
async def test_event(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test event entity for Hue integration."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -63,7 +66,7 @@ async def test_event(
|
||||
assert state.attributes[ATTR_EVENT_TYPE] == "long_release"
|
||||
|
||||
|
||||
async def test_sensor_add_update(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
async def test_sensor_add_update(hass: HomeAssistant, mock_bridge_v2: Mock) -> None:
|
||||
"""Test Event entity for newly added Relative Rotary resource."""
|
||||
await mock_bridge_v2.api.load_test_data([FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY])
|
||||
await setup_platform(hass, mock_bridge_v2, "event")
|
||||
|
@ -175,7 +175,7 @@ LIGHT_GAMUT = color.GamutType(
|
||||
LIGHT_GAMUT_TYPE = "A"
|
||||
|
||||
|
||||
async def setup_bridge(hass: HomeAssistant, mock_bridge_v1):
|
||||
async def setup_bridge(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Load the Hue light platform with the provided bridge."""
|
||||
hass.config.components.add(hue.DOMAIN)
|
||||
config_entry = create_config_entry()
|
||||
@ -192,7 +192,7 @@ async def setup_bridge(hass: HomeAssistant, mock_bridge_v1):
|
||||
|
||||
|
||||
async def test_not_load_groups_if_old_bridge(
|
||||
hass: HomeAssistant, mock_bridge_v1
|
||||
hass: HomeAssistant, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test that we don't try to load groups if bridge runs old software."""
|
||||
mock_bridge_v1.api.config.apiversion = "1.12.0"
|
||||
@ -203,7 +203,7 @@ async def test_not_load_groups_if_old_bridge(
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_no_lights_or_groups(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_no_lights_or_groups(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test the update_lights function when no lights are found."""
|
||||
mock_bridge_v1.mock_light_responses.append({})
|
||||
mock_bridge_v1.mock_group_responses.append({})
|
||||
@ -212,7 +212,7 @@ async def test_no_lights_or_groups(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_lights(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_lights(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test the update_lights function with some lights."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -232,7 +232,7 @@ async def test_lights(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert lamp_2.state == "off"
|
||||
|
||||
|
||||
async def test_lights_color_mode(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_lights_color_mode(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test that lights only report appropriate color mode."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
mock_bridge_v1.mock_group_responses.append(GROUP_RESPONSE)
|
||||
@ -278,7 +278,7 @@ async def test_lights_color_mode(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
|
||||
|
||||
async def test_groups(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_bridge_v1
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test the update_lights function with some lights."""
|
||||
mock_bridge_v1.mock_light_responses.append({})
|
||||
@ -303,7 +303,7 @@ async def test_groups(
|
||||
assert entity_registry.async_get("light.group_2").unique_id == "2"
|
||||
|
||||
|
||||
async def test_new_group_discovered(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_new_group_discovered(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has a new group."""
|
||||
mock_bridge_v1.allow_groups = True
|
||||
mock_bridge_v1.mock_light_responses.append({})
|
||||
@ -350,7 +350,7 @@ async def test_new_group_discovered(hass: HomeAssistant, mock_bridge_v1) -> None
|
||||
assert new_group.attributes["color_temp"] == 250
|
||||
|
||||
|
||||
async def test_new_light_discovered(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_new_light_discovered(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has a new light."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -396,7 +396,7 @@ async def test_new_light_discovered(hass: HomeAssistant, mock_bridge_v1) -> None
|
||||
assert light.state == "off"
|
||||
|
||||
|
||||
async def test_group_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_group_removed(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has removed group."""
|
||||
mock_bridge_v1.allow_groups = True
|
||||
mock_bridge_v1.mock_light_responses.append({})
|
||||
@ -427,7 +427,7 @@ async def test_group_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert removed_group is None
|
||||
|
||||
|
||||
async def test_light_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_light_removed(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has removed light."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -456,7 +456,7 @@ async def test_light_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert removed_light is None
|
||||
|
||||
|
||||
async def test_other_group_update(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_other_group_update(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test changing one group that will impact the state of other light."""
|
||||
mock_bridge_v1.allow_groups = True
|
||||
mock_bridge_v1.mock_light_responses.append({})
|
||||
@ -509,7 +509,7 @@ async def test_other_group_update(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert group_2.state == "off"
|
||||
|
||||
|
||||
async def test_other_light_update(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_other_light_update(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test changing one light that will impact state of other light."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -562,7 +562,7 @@ async def test_other_light_update(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert lamp_2.attributes["brightness"] == 100
|
||||
|
||||
|
||||
async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test bridge marked as not available if timeout error during update."""
|
||||
mock_bridge_v1.api.lights.update = Mock(side_effect=TimeoutError)
|
||||
mock_bridge_v1.api.groups.update = Mock(side_effect=TimeoutError)
|
||||
@ -571,7 +571,7 @@ async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test bridge marked as not authorized if unauthorized during update."""
|
||||
mock_bridge_v1.api.lights.update = Mock(side_effect=aiohue.Unauthorized)
|
||||
await setup_bridge(hass, mock_bridge_v1)
|
||||
@ -580,7 +580,7 @@ async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert len(mock_bridge_v1.handle_unauthorized_error.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_light_turn_on_service(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_light_turn_on_service(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test calling the turn on service on a light."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -633,7 +633,9 @@ async def test_light_turn_on_service(hass: HomeAssistant, mock_bridge_v1) -> Non
|
||||
}
|
||||
|
||||
|
||||
async def test_light_turn_off_service(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_light_turn_off_service(
|
||||
hass: HomeAssistant, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test calling the turn on service on a light."""
|
||||
mock_bridge_v1.mock_light_responses.append(LIGHT_RESPONSE)
|
||||
|
||||
@ -775,7 +777,7 @@ async def test_group_features(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v1: Mock,
|
||||
) -> None:
|
||||
"""Test group features."""
|
||||
color_temp_type = "Color temperature light"
|
||||
|
@ -1,15 +1,18 @@
|
||||
"""Philips Hue lights platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.components.light import ColorMode
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
from .const import FAKE_DEVICE, FAKE_LIGHT, FAKE_ZIGBEE_CONNECTIVITY
|
||||
|
||||
|
||||
async def test_lights(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test if all v2 lights get created with correct features."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -77,7 +80,7 @@ async def test_lights(
|
||||
|
||||
|
||||
async def test_light_turn_on_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the turn on service on a light."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -229,7 +232,7 @@ async def test_light_turn_on_service(
|
||||
|
||||
|
||||
async def test_light_turn_off_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the turn off service on a light."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -318,7 +321,7 @@ async def test_light_turn_off_service(
|
||||
assert mock_bridge_v2.mock_requests[4]["json"]["identify"]["action"] == "identify"
|
||||
|
||||
|
||||
async def test_light_added(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
async def test_light_added(hass: HomeAssistant, mock_bridge_v2: Mock) -> None:
|
||||
"""Test new light added to bridge."""
|
||||
await mock_bridge_v2.api.load_test_data([FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY])
|
||||
|
||||
@ -341,7 +344,7 @@ async def test_light_added(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
|
||||
|
||||
async def test_light_availability(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test light availability property."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -375,8 +378,8 @@ async def test_light_availability(
|
||||
async def test_grouped_lights(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if all v2 grouped lights get created with correct features."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
|
@ -1,10 +1,11 @@
|
||||
"""Test Hue migration logic."""
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components import hue
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -51,9 +52,9 @@ async def test_light_entity_migration(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if entity schema for lights migrates from v1 to v2."""
|
||||
config_entry = mock_bridge_v2.config_entry = mock_config_entry_v2
|
||||
@ -98,9 +99,9 @@ async def test_sensor_entity_migration(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if entity schema for sensors migrates from v1 to v2."""
|
||||
config_entry = mock_bridge_v2.config_entry = mock_config_entry_v2
|
||||
@ -159,9 +160,9 @@ async def test_sensor_entity_migration(
|
||||
async def test_group_entity_migration_with_v1_id(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if entity schema for grouped_lights migrates from v1 to v2."""
|
||||
config_entry = mock_bridge_v2.config_entry = mock_config_entry_v2
|
||||
@ -194,9 +195,9 @@ async def test_group_entity_migration_with_v1_id(
|
||||
async def test_group_entity_migration_with_v2_group_id(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if entity schema for grouped_lights migrates from v1 to v2."""
|
||||
config_entry = mock_bridge_v2.config_entry = mock_config_entry_v2
|
||||
|
@ -1,8 +1,11 @@
|
||||
"""Philips Hue scene platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
from .const import FAKE_SCENE
|
||||
@ -11,8 +14,8 @@ from .const import FAKE_SCENE
|
||||
async def test_scene(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if (config) scenes get created."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -72,7 +75,7 @@ async def test_scene(
|
||||
|
||||
|
||||
async def test_scene_turn_on_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the turn on service on a scene."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -109,7 +112,7 @@ async def test_scene_turn_on_service(
|
||||
|
||||
|
||||
async def test_scene_advanced_turn_on_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the advanced turn on service on a scene."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -146,7 +149,7 @@ async def test_scene_advanced_turn_on_service(
|
||||
|
||||
|
||||
async def test_scene_updates(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test scene events from bridge."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
|
@ -282,7 +282,7 @@ SENSOR_RESPONSE = {
|
||||
}
|
||||
|
||||
|
||||
async def test_no_sensors(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_no_sensors(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test the update_items function when no sensors are found."""
|
||||
mock_bridge_v1.mock_sensor_responses.append({})
|
||||
await setup_platform(hass, mock_bridge_v1, ["binary_sensor", "sensor"])
|
||||
@ -291,7 +291,7 @@ async def test_no_sensors(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
|
||||
|
||||
async def test_sensors_with_multiple_bridges(
|
||||
hass: HomeAssistant, mock_bridge_v1
|
||||
hass: HomeAssistant, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test the update_items function with some sensors."""
|
||||
mock_bridge_2 = create_mock_bridge(hass, api_version=1)
|
||||
@ -315,7 +315,7 @@ async def test_sensors_with_multiple_bridges(
|
||||
|
||||
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_bridge_v1
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_bridge_v1: Mock
|
||||
) -> None:
|
||||
"""Test the update_items function with some sensors."""
|
||||
mock_bridge_v1.mock_sensor_responses.append(SENSOR_RESPONSE)
|
||||
@ -361,7 +361,7 @@ async def test_sensors(
|
||||
)
|
||||
|
||||
|
||||
async def test_unsupported_sensors(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_unsupported_sensors(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test that unsupported sensors don't get added and don't fail."""
|
||||
response_with_unsupported = dict(SENSOR_RESPONSE)
|
||||
response_with_unsupported["7"] = UNSUPPORTED_SENSOR
|
||||
@ -372,7 +372,7 @@ async def test_unsupported_sensors(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert len(hass.states.async_all()) == 7
|
||||
|
||||
|
||||
async def test_new_sensor_discovered(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_new_sensor_discovered(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has a new sensor."""
|
||||
mock_bridge_v1.mock_sensor_responses.append(SENSOR_RESPONSE)
|
||||
|
||||
@ -406,7 +406,7 @@ async def test_new_sensor_discovered(hass: HomeAssistant, mock_bridge_v1) -> Non
|
||||
assert temperature.state == "17.75"
|
||||
|
||||
|
||||
async def test_sensor_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_sensor_removed(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test if 2nd update has removed sensor."""
|
||||
mock_bridge_v1.mock_sensor_responses.append(SENSOR_RESPONSE)
|
||||
|
||||
@ -434,7 +434,7 @@ async def test_sensor_removed(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert removed_sensor is None
|
||||
|
||||
|
||||
async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test bridge marked as not available if timeout error during update."""
|
||||
mock_bridge_v1.api.sensors.update = Mock(side_effect=TimeoutError)
|
||||
await setup_platform(hass, mock_bridge_v1, ["binary_sensor", "sensor"])
|
||||
@ -442,7 +442,7 @@ async def test_update_timeout(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1: Mock) -> None:
|
||||
"""Test bridge marked as not authorized if unauthorized during update."""
|
||||
mock_bridge_v1.api.sensors.update = Mock(side_effect=aiohue.Unauthorized)
|
||||
await setup_platform(hass, mock_bridge_v1, ["binary_sensor", "sensor"])
|
||||
@ -454,7 +454,7 @@ async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1) -> None:
|
||||
async def test_hue_events(
|
||||
hass: HomeAssistant,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v1: Mock,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test that hue remotes fire events when pressed."""
|
||||
|
@ -1,19 +1,24 @@
|
||||
"""Philips Hue sensor platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.components import hue
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_bridge, setup_platform
|
||||
from .const import FAKE_DEVICE, FAKE_SENSOR, FAKE_ZIGBEE_CONNECTIVITY
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
v2_resources_test_data,
|
||||
mock_bridge_v2: Mock,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
) -> None:
|
||||
"""Test if all v2 sensors get created with correct features."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -65,9 +70,9 @@ async def test_sensors(
|
||||
async def test_enable_sensor(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_bridge_v2,
|
||||
v2_resources_test_data,
|
||||
mock_config_entry_v2,
|
||||
mock_bridge_v2: Mock,
|
||||
v2_resources_test_data: JsonArrayType,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test enabling of the by default disabled zigbee_connectivity sensor."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -105,7 +110,7 @@ async def test_enable_sensor(
|
||||
assert state.attributes["mac_address"] == "00:17:88:01:0b:aa:bb:99"
|
||||
|
||||
|
||||
async def test_sensor_add_update(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
async def test_sensor_add_update(hass: HomeAssistant, mock_bridge_v2: Mock) -> None:
|
||||
"""Test if sensors get added/updated from events."""
|
||||
await mock_bridge_v2.api.load_test_data([FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY])
|
||||
await setup_platform(hass, mock_bridge_v2, "sensor")
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Test Hue services."""
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.components import hue
|
||||
from homeassistant.components.hue import bridge
|
||||
@ -48,7 +48,7 @@ SCENE_RESPONSE = {
|
||||
}
|
||||
|
||||
|
||||
async def test_hue_activate_scene(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
async def test_hue_activate_scene(hass: HomeAssistant, mock_api_v1: Mock) -> None:
|
||||
"""Test successful hue_activate_scene."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=hue.DOMAIN,
|
||||
@ -83,7 +83,9 @@ async def test_hue_activate_scene(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
assert mock_api_v1.mock_requests[2]["path"] == "groups/group_1/action"
|
||||
|
||||
|
||||
async def test_hue_activate_scene_transition(hass: HomeAssistant, mock_api_v1) -> None:
|
||||
async def test_hue_activate_scene_transition(
|
||||
hass: HomeAssistant, mock_api_v1: Mock
|
||||
) -> None:
|
||||
"""Test successful hue_activate_scene with transition."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=hue.DOMAIN,
|
||||
@ -119,7 +121,7 @@ async def test_hue_activate_scene_transition(hass: HomeAssistant, mock_api_v1) -
|
||||
|
||||
|
||||
async def test_hue_activate_scene_group_not_found(
|
||||
hass: HomeAssistant, mock_api_v1
|
||||
hass: HomeAssistant, mock_api_v1: Mock
|
||||
) -> None:
|
||||
"""Test failed hue_activate_scene due to missing group."""
|
||||
config_entry = MockConfigEntry(
|
||||
@ -151,7 +153,7 @@ async def test_hue_activate_scene_group_not_found(
|
||||
|
||||
|
||||
async def test_hue_activate_scene_scene_not_found(
|
||||
hass: HomeAssistant, mock_api_v1
|
||||
hass: HomeAssistant, mock_api_v1: Mock
|
||||
) -> None:
|
||||
"""Test failed hue_activate_scene due to missing scene."""
|
||||
config_entry = MockConfigEntry(
|
||||
@ -184,10 +186,10 @@ async def test_hue_activate_scene_scene_not_found(
|
||||
|
||||
async def test_hue_multi_bridge_activate_scene_all_respond(
|
||||
hass: HomeAssistant,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v1,
|
||||
mock_config_entry_v2,
|
||||
mock_bridge_v1: Mock,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v1: MockConfigEntry,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that makes multiple bridges successfully activate a scene."""
|
||||
await setup_component(hass)
|
||||
@ -218,10 +220,10 @@ async def test_hue_multi_bridge_activate_scene_all_respond(
|
||||
|
||||
async def test_hue_multi_bridge_activate_scene_one_responds(
|
||||
hass: HomeAssistant,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v1,
|
||||
mock_config_entry_v2,
|
||||
mock_bridge_v1: Mock,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v1: MockConfigEntry,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that makes only one bridge successfully activate a scene."""
|
||||
await setup_component(hass)
|
||||
@ -251,10 +253,10 @@ async def test_hue_multi_bridge_activate_scene_one_responds(
|
||||
|
||||
async def test_hue_multi_bridge_activate_scene_zero_responds(
|
||||
hass: HomeAssistant,
|
||||
mock_bridge_v1,
|
||||
mock_bridge_v2,
|
||||
mock_config_entry_v1,
|
||||
mock_config_entry_v2,
|
||||
mock_bridge_v1: Mock,
|
||||
mock_bridge_v2: Mock,
|
||||
mock_config_entry_v1: MockConfigEntry,
|
||||
mock_config_entry_v2: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that makes no bridge successfully activate a scene."""
|
||||
await setup_component(hass)
|
||||
|
@ -1,13 +1,16 @@
|
||||
"""Philips Hue switch platform tests for V2 bridge/api."""
|
||||
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.json import JsonArrayType
|
||||
|
||||
from .conftest import setup_platform
|
||||
from .const import FAKE_BINARY_SENSOR, FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY
|
||||
|
||||
|
||||
async def test_switch(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test if (config) switches get created."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -34,7 +37,7 @@ async def test_switch(
|
||||
|
||||
|
||||
async def test_switch_turn_on_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the turn on service on a switch."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -58,7 +61,7 @@ async def test_switch_turn_on_service(
|
||||
|
||||
|
||||
async def test_switch_turn_off_service(
|
||||
hass: HomeAssistant, mock_bridge_v2, v2_resources_test_data
|
||||
hass: HomeAssistant, mock_bridge_v2: Mock, v2_resources_test_data: JsonArrayType
|
||||
) -> None:
|
||||
"""Test calling the turn off service on a switch."""
|
||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||
@ -98,7 +101,7 @@ async def test_switch_turn_off_service(
|
||||
assert test_entity.state == "off"
|
||||
|
||||
|
||||
async def test_switch_added(hass: HomeAssistant, mock_bridge_v2) -> None:
|
||||
async def test_switch_added(hass: HomeAssistant, mock_bridge_v2: Mock) -> None:
|
||||
"""Test new switch added to bridge."""
|
||||
await mock_bridge_v2.api.load_test_data([FAKE_DEVICE, FAKE_ZIGBEE_CONNECTIVITY])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user