mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Use common registry fixtures in hue (#121003)
This commit is contained in:
parent
e3516be3e3
commit
9ca9377cad
@ -20,7 +20,7 @@ from homeassistant.setup import async_setup_component
|
|||||||
|
|
||||||
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
from .const import FAKE_BRIDGE, FAKE_BRIDGE_DEVICE
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, load_fixture, mock_device_registry
|
from tests.common import MockConfigEntry, load_fixture
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@ -276,9 +276,3 @@ async def setup_platform(
|
|||||||
|
|
||||||
# and make sure it completes before going further
|
# and make sure it completes before going further
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="device_reg")
|
|
||||||
def get_device_reg(hass):
|
|
||||||
"""Return an empty, loaded, registry."""
|
|
||||||
return mock_device_registry(hass)
|
|
||||||
|
@ -21,7 +21,7 @@ async def test_get_triggers(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
mock_bridge_v1,
|
mock_bridge_v1,
|
||||||
device_reg: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we get the expected triggers from a hue remote."""
|
"""Test we get the expected triggers from a hue remote."""
|
||||||
mock_bridge_v1.mock_sensor_responses.append(REMOTES_RESPONSE)
|
mock_bridge_v1.mock_sensor_responses.append(REMOTES_RESPONSE)
|
||||||
@ -32,7 +32,7 @@ async def test_get_triggers(
|
|||||||
assert len(hass.states.async_all()) == 1
|
assert len(hass.states.async_all()) == 1
|
||||||
|
|
||||||
# Get triggers for specific tap switch
|
# Get triggers for specific tap switch
|
||||||
hue_tap_device = device_reg.async_get_device(
|
hue_tap_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
||||||
)
|
)
|
||||||
triggers = await async_get_device_automations(
|
triggers = await async_get_device_automations(
|
||||||
@ -53,7 +53,7 @@ async def test_get_triggers(
|
|||||||
assert triggers == unordered(expected_triggers)
|
assert triggers == unordered(expected_triggers)
|
||||||
|
|
||||||
# Get triggers for specific dimmer switch
|
# Get triggers for specific dimmer switch
|
||||||
hue_dimmer_device = device_reg.async_get_device(
|
hue_dimmer_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "00:17:88:01:10:3e:3a:dc")}
|
identifiers={(hue.DOMAIN, "00:17:88:01:10:3e:3a:dc")}
|
||||||
)
|
)
|
||||||
hue_bat_sensor = entity_registry.async_get(
|
hue_bat_sensor = entity_registry.async_get(
|
||||||
@ -91,7 +91,7 @@ async def test_get_triggers(
|
|||||||
async def test_if_fires_on_state_change(
|
async def test_if_fires_on_state_change(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_bridge_v1,
|
mock_bridge_v1,
|
||||||
device_reg: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
service_calls: list[ServiceCall],
|
service_calls: list[ServiceCall],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for button press trigger firing."""
|
"""Test for button press trigger firing."""
|
||||||
@ -101,7 +101,7 @@ async def test_if_fires_on_state_change(
|
|||||||
assert len(hass.states.async_all()) == 1
|
assert len(hass.states.async_all()) == 1
|
||||||
|
|
||||||
# Set an automation with a specific tap switch trigger
|
# Set an automation with a specific tap switch trigger
|
||||||
hue_tap_device = device_reg.async_get_device(
|
hue_tap_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
||||||
)
|
)
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
@ -8,7 +8,7 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
|||||||
from homeassistant.components.hue.v2.device import async_setup_devices
|
from homeassistant.components.hue.v2.device import async_setup_devices
|
||||||
from homeassistant.components.hue.v2.hue_event import async_setup_hue_events
|
from homeassistant.components.hue.v2.hue_event import async_setup_hue_events
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from .conftest import setup_platform
|
from .conftest import setup_platform
|
||||||
|
|
||||||
@ -50,14 +50,14 @@ async def test_get_triggers(
|
|||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
mock_bridge_v2,
|
mock_bridge_v2,
|
||||||
v2_resources_test_data,
|
v2_resources_test_data,
|
||||||
device_reg,
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test we get the expected triggers from a hue remote."""
|
"""Test we get the expected triggers from a hue remote."""
|
||||||
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
await mock_bridge_v2.api.load_test_data(v2_resources_test_data)
|
||||||
await setup_platform(hass, mock_bridge_v2, ["binary_sensor", "sensor"])
|
await setup_platform(hass, mock_bridge_v2, ["binary_sensor", "sensor"])
|
||||||
|
|
||||||
# Get triggers for `Wall switch with 2 controls`
|
# Get triggers for `Wall switch with 2 controls`
|
||||||
hue_wall_switch_device = device_reg.async_get_device(
|
hue_wall_switch_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "3ff06175-29e8-44a8-8fe7-af591b0025da")}
|
identifiers={(hue.DOMAIN, "3ff06175-29e8-44a8-8fe7-af591b0025da")}
|
||||||
)
|
)
|
||||||
hue_bat_sensor = entity_registry.async_get(
|
hue_bat_sensor = entity_registry.async_get(
|
||||||
|
@ -10,7 +10,7 @@ from homeassistant.components.hue.const import ATTR_HUE_EVENT
|
|||||||
from homeassistant.components.hue.v1 import sensor_base
|
from homeassistant.components.hue.v1 import sensor_base
|
||||||
from homeassistant.const import EntityCategory
|
from homeassistant.const import EntityCategory
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from .conftest import create_mock_bridge, setup_platform
|
from .conftest import create_mock_bridge, setup_platform
|
||||||
|
|
||||||
@ -452,7 +452,10 @@ async def test_update_unauthorized(hass: HomeAssistant, mock_bridge_v1) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def test_hue_events(
|
async def test_hue_events(
|
||||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, mock_bridge_v1, device_reg
|
hass: HomeAssistant,
|
||||||
|
freezer: FrozenDateTimeFactory,
|
||||||
|
mock_bridge_v1,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that hue remotes fire events when pressed."""
|
"""Test that hue remotes fire events when pressed."""
|
||||||
mock_bridge_v1.mock_sensor_responses.append(SENSOR_RESPONSE)
|
mock_bridge_v1.mock_sensor_responses.append(SENSOR_RESPONSE)
|
||||||
@ -464,7 +467,7 @@ async def test_hue_events(
|
|||||||
assert len(hass.states.async_all()) == 7
|
assert len(hass.states.async_all()) == 7
|
||||||
assert len(events) == 0
|
assert len(events) == 0
|
||||||
|
|
||||||
hue_tap_device = device_reg.async_get_device(
|
hue_tap_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
identifiers={(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -495,7 +498,7 @@ async def test_hue_events(
|
|||||||
"last_updated": "2019-12-28T22:58:03",
|
"last_updated": "2019-12-28T22:58:03",
|
||||||
}
|
}
|
||||||
|
|
||||||
hue_dimmer_device = device_reg.async_get_device(
|
hue_dimmer_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "00:17:88:01:10:3e:3a:dc")}
|
identifiers={(hue.DOMAIN, "00:17:88:01:10:3e:3a:dc")}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -594,7 +597,7 @@ async def test_hue_events(
|
|||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
hue_aurora_device = device_reg.async_get_device(
|
hue_aurora_device = device_registry.async_get_device(
|
||||||
identifiers={(hue.DOMAIN, "ff:ff:00:0f:e7:fd:bc:b7")}
|
identifiers={(hue.DOMAIN, "ff:ff:00:0f:e7:fd:bc:b7")}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user