mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Use fixtures in deCONZ logbook tests (#120947)
This commit is contained in:
parent
a0b604f98c
commit
d506c30b38
@ -1,6 +1,8 @@
|
||||
"""The tests for deCONZ logbook."""
|
||||
|
||||
from unittest.mock import patch
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.deconz.const import CONF_GESTURE, DOMAIN as DECONZ_DOMAIN
|
||||
from homeassistant.components.deconz.deconz_event import (
|
||||
@ -21,20 +23,13 @@ from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import slugify
|
||||
|
||||
from .test_gateway import DECONZ_WEB_REQUEST, setup_deconz_integration
|
||||
|
||||
from tests.components.logbook.common import MockRow, mock_humanify
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
|
||||
async def test_humanifying_deconz_alarm_event(
|
||||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test humanifying deCONZ event."""
|
||||
data = {
|
||||
"sensors": {
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
[
|
||||
{
|
||||
"1": {
|
||||
"config": {
|
||||
"armed": "disarmed",
|
||||
@ -60,12 +55,17 @@ async def test_humanifying_deconz_alarm_event(
|
||||
"uniqueid": "00:0d:6f:00:13:4f:61:39-01-0501",
|
||||
}
|
||||
}
|
||||
}
|
||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
||||
await setup_deconz_integration(hass, aioclient_mock)
|
||||
|
||||
keypad_event_id = slugify(data["sensors"]["1"]["name"])
|
||||
keypad_serial = serial_from_unique_id(data["sensors"]["1"]["uniqueid"])
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("config_entry_setup")
|
||||
async def test_humanifying_deconz_alarm_event(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
sensor_payload: dict[str, Any],
|
||||
) -> None:
|
||||
"""Test humanifying deCONZ alarm event."""
|
||||
keypad_event_id = slugify(sensor_payload["1"]["name"])
|
||||
keypad_serial = serial_from_unique_id(sensor_payload["1"]["uniqueid"])
|
||||
keypad_entry = device_registry.async_get_device(
|
||||
identifiers={(DECONZ_DOMAIN, keypad_serial)}
|
||||
)
|
||||
@ -113,14 +113,10 @@ async def test_humanifying_deconz_alarm_event(
|
||||
assert events[1]["message"] == "fired event 'armed_away'"
|
||||
|
||||
|
||||
async def test_humanifying_deconz_event(
|
||||
hass: HomeAssistant,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
) -> None:
|
||||
"""Test humanifying deCONZ event."""
|
||||
data = {
|
||||
"sensors": {
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
[
|
||||
{
|
||||
"1": {
|
||||
"name": "Switch 1",
|
||||
"type": "ZHASwitch",
|
||||
@ -152,30 +148,35 @@ async def test_humanifying_deconz_event(
|
||||
"uniqueid": "00:00:00:00:00:00:00:04-00",
|
||||
},
|
||||
}
|
||||
}
|
||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
||||
await setup_deconz_integration(hass, aioclient_mock)
|
||||
|
||||
switch_event_id = slugify(data["sensors"]["1"]["name"])
|
||||
switch_serial = serial_from_unique_id(data["sensors"]["1"]["uniqueid"])
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("config_entry_setup")
|
||||
async def test_humanifying_deconz_event(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
sensor_payload: dict[str, Any],
|
||||
) -> None:
|
||||
"""Test humanifying deCONZ event."""
|
||||
switch_event_id = slugify(sensor_payload["1"]["name"])
|
||||
switch_serial = serial_from_unique_id(sensor_payload["1"]["uniqueid"])
|
||||
switch_entry = device_registry.async_get_device(
|
||||
identifiers={(DECONZ_DOMAIN, switch_serial)}
|
||||
)
|
||||
|
||||
hue_remote_event_id = slugify(data["sensors"]["2"]["name"])
|
||||
hue_remote_serial = serial_from_unique_id(data["sensors"]["2"]["uniqueid"])
|
||||
hue_remote_event_id = slugify(sensor_payload["2"]["name"])
|
||||
hue_remote_serial = serial_from_unique_id(sensor_payload["2"]["uniqueid"])
|
||||
hue_remote_entry = device_registry.async_get_device(
|
||||
identifiers={(DECONZ_DOMAIN, hue_remote_serial)}
|
||||
)
|
||||
|
||||
xiaomi_cube_event_id = slugify(data["sensors"]["3"]["name"])
|
||||
xiaomi_cube_serial = serial_from_unique_id(data["sensors"]["3"]["uniqueid"])
|
||||
xiaomi_cube_event_id = slugify(sensor_payload["3"]["name"])
|
||||
xiaomi_cube_serial = serial_from_unique_id(sensor_payload["3"]["uniqueid"])
|
||||
xiaomi_cube_entry = device_registry.async_get_device(
|
||||
identifiers={(DECONZ_DOMAIN, xiaomi_cube_serial)}
|
||||
)
|
||||
|
||||
faulty_event_id = slugify(data["sensors"]["4"]["name"])
|
||||
faulty_serial = serial_from_unique_id(data["sensors"]["4"]["uniqueid"])
|
||||
faulty_event_id = slugify(sensor_payload["4"]["name"])
|
||||
faulty_serial = serial_from_unique_id(sensor_payload["4"]["uniqueid"])
|
||||
faulty_entry = device_registry.async_get_device(
|
||||
identifiers={(DECONZ_DOMAIN, faulty_serial)}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user