Use DeviceAutomationType in tests/components/[h-l]* (#62441)
This commit is contained in:
parent
ce93364a36
commit
c5e6489475
20 changed files with 108 additions and 30 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.homekit.type_triggers import DeviceTriggerAccessory
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -26,7 +27,9 @@ async def test_programmable_switch_button_fires_on_trigger(
|
|||
assert entry is not None
|
||||
device_id = entry.device_id
|
||||
|
||||
device_triggers = await async_get_device_automations(hass, "trigger", device_id)
|
||||
device_triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_id
|
||||
)
|
||||
acc = DeviceTriggerAccessory(
|
||||
hass,
|
||||
hk_driver,
|
||||
|
|
|
@ -7,6 +7,7 @@ service-label-index despite not being linked to a service-label.
|
|||
https://github.com/home-assistant/core/pull/39090
|
||||
"""
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.common import assert_lists_same, async_get_device_automations
|
||||
|
@ -50,5 +51,7 @@ async def test_aqara_switch_setup(hass):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", battery.device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, battery.device_id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Tests for handling accessories on a Hue bridge via HomeKit."""
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import assert_lists_same, async_get_device_automations
|
||||
|
@ -63,5 +64,7 @@ async def test_hue_bridge_setup(hass):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Make sure that handling real world LG HomeKit characteristics isn't broken."""
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
|
@ -66,6 +67,8 @@ async def test_lg_tv(hass):
|
|||
assert device.hw_version == "1"
|
||||
|
||||
# A TV has media player device triggers
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
for trigger in triggers:
|
||||
assert trigger["domain"] == "media_player"
|
||||
|
|
|
@ -4,6 +4,7 @@ Regression tests for Netamo Doorbell.
|
|||
https://github.com/home-assistant/core/issues/44596
|
||||
"""
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import assert_lists_same, async_get_device_automations
|
||||
|
@ -69,5 +70,7 @@ async def test_netamo_doorbell_setup(hass):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", doorbell.device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, doorbell.device_id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
|
|
@ -4,6 +4,7 @@ from aiohomekit.model.services import ServicesTypes
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.homekit_controller.const import DOMAIN
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -111,7 +112,9 @@ async def test_enumerate_remote(hass, utcnow):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
||||
|
||||
|
@ -146,7 +149,9 @@ async def test_enumerate_button(hass, utcnow):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
||||
|
||||
|
@ -181,7 +186,9 @@ async def test_enumerate_doorbell(hass, utcnow):
|
|||
}
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""The tests for Philips Hue device triggers for V1 bridge."""
|
||||
|
||||
from homeassistant.components import automation, hue
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.hue.v1 import device_trigger
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -25,7 +26,9 @@ async def test_get_triggers(hass, mock_bridge_v1, device_reg):
|
|||
hue_tap_device = device_reg.async_get_device(
|
||||
{(hue.DOMAIN, "00:00:00:00:00:44:23:08")}
|
||||
)
|
||||
triggers = await async_get_device_automations(hass, "trigger", hue_tap_device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, hue_tap_device.id
|
||||
)
|
||||
|
||||
expected_triggers = [
|
||||
{
|
||||
|
@ -43,7 +46,9 @@ async def test_get_triggers(hass, mock_bridge_v1, device_reg):
|
|||
hue_dimmer_device = device_reg.async_get_device(
|
||||
{(hue.DOMAIN, "00:17:88:01:10:3e:3a:dc")}
|
||||
)
|
||||
triggers = await async_get_device_automations(hass, "trigger", hue_dimmer_device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, hue_dimmer_device.id
|
||||
)
|
||||
|
||||
trigger_batt = {
|
||||
"platform": "device",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from aiohue.v2.models.button import ButtonEvent
|
||||
|
||||
from homeassistant.components import hue
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.hue.v2.device import async_setup_devices
|
||||
from homeassistant.components.hue.v2.hue_event import async_setup_hue_events
|
||||
|
||||
|
@ -52,7 +53,7 @@ async def test_get_triggers(hass, mock_bridge_v2, v2_resources_test_data, device
|
|||
{(hue.DOMAIN, "3ff06175-29e8-44a8-8fe7-af591b0025da")}
|
||||
)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, "trigger", hue_wall_switch_device.id
|
||||
hass, DeviceAutomationType.TRIGGER, hue_wall_switch_device.id
|
||||
)
|
||||
|
||||
trigger_batt = {
|
||||
|
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.humidifier import DOMAIN, const, device_action
|
||||
from homeassistant.const import STATE_ON
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
|
@ -87,7 +88,9 @@ async def test_get_actions(
|
|||
}
|
||||
for action in expected_action_types
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert_lists_same(actions, expected_actions)
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.humidifier import DOMAIN, const, device_condition
|
||||
from homeassistant.const import ATTR_MODE, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
|
@ -95,7 +96,9 @@ async def test_get_conditions(
|
|||
}
|
||||
for condition in expected_condition_types
|
||||
]
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
assert_lists_same(conditions, expected_conditions)
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.humidifier import DOMAIN, const, device_trigger
|
||||
from homeassistant.const import ATTR_MODE, ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
|
@ -84,7 +85,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.kodi import DOMAIN
|
||||
from homeassistant.components.media_player.const import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -70,7 +71,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
]
|
||||
|
||||
# Test triggers are either kodi specific triggers or media_player entity triggers
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
for expected_trigger in expected_triggers:
|
||||
assert expected_trigger in triggers
|
||||
for trigger in triggers:
|
||||
|
|
|
@ -5,6 +5,7 @@ from pypck.lcn_defs import AccessControlPeriphery, KeyAction, SendKeyCommand
|
|||
import voluptuous_serialize
|
||||
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.lcn import device_trigger
|
||||
from homeassistant.components.lcn.const import DOMAIN, KEY_ACTIONS, SENDKEYS
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_DOMAIN, CONF_PLATFORM, CONF_TYPE
|
||||
|
@ -47,7 +48,9 @@ async def test_get_triggers_module_device(hass, entry, lcn_connection):
|
|||
},
|
||||
]
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -63,7 +66,9 @@ async def test_get_triggers_non_module_device(hass, entry, lcn_connection):
|
|||
)
|
||||
|
||||
for device in (host_device, group_device, resource_device):
|
||||
triggers = await async_get_device_automations(hass, "trigger", device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device.id
|
||||
)
|
||||
for trigger in triggers:
|
||||
assert trigger[CONF_TYPE] not in not_included_types
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.light import (
|
||||
ATTR_SUPPORTED_COLOR_MODES,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
|
@ -97,7 +98,9 @@ async def test_get_actions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert actions == expected_actions
|
||||
|
||||
|
||||
|
@ -116,7 +119,9 @@ async def test_get_action_capabilities(hass, device_reg, entity_reg):
|
|||
"5678",
|
||||
device_id=device_entry.id,
|
||||
).entity_id
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert len(actions) == 3
|
||||
action_types = {action["type"] for action in actions}
|
||||
assert action_types == {"turn_on", "toggle", "turn_off"}
|
||||
|
@ -260,7 +265,9 @@ async def test_get_action_capabilities_features(
|
|||
{"supported_features": supported_features_state, **attributes_state},
|
||||
)
|
||||
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert len(actions) == len(expected_actions)
|
||||
action_types = {action["type"] for action in actions}
|
||||
assert action_types == expected_actions
|
||||
|
|
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.light import DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import device_registry
|
||||
|
@ -65,7 +66,9 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
assert conditions == expected_conditions
|
||||
|
||||
|
||||
|
@ -83,7 +86,9 @@ async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
|||
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
||||
]
|
||||
}
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
for condition in conditions:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
hass, "condition", condition
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.light import DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import device_registry
|
||||
|
@ -65,7 +66,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert triggers == expected_triggers
|
||||
|
||||
|
||||
|
@ -83,7 +86,9 @@ async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
|
|||
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
||||
]
|
||||
}
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
for trigger in triggers:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
hass, "trigger", trigger
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.lock import DOMAIN, SUPPORT_OPEN
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -85,7 +86,9 @@ async def test_get_actions(
|
|||
}
|
||||
for action in expected_action_types
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert_lists_same(actions, expected_actions)
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.lock import DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_JAMMED,
|
||||
|
@ -88,7 +89,9 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
assert_lists_same(conditions, expected_conditions)
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.lock import DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_JAMMED,
|
||||
|
@ -93,7 +94,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -107,7 +110,9 @@ async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
|
|||
)
|
||||
entity_reg.async_get_or_create(DOMAIN, "test", "5678", device_id=device_entry.id)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 5
|
||||
for trigger in triggers:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
from homeassistant.components import automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.device_automation.exceptions import (
|
||||
InvalidDeviceAutomationConfig,
|
||||
)
|
||||
|
@ -166,7 +167,9 @@ async def test_get_triggers(hass, device_reg):
|
|||
},
|
||||
]
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -180,7 +183,9 @@ async def test_get_triggers_for_invalid_device_id(hass, device_reg):
|
|||
)
|
||||
|
||||
with pytest.raises(InvalidDeviceAutomationConfig):
|
||||
await async_get_device_automations(hass, "trigger", invalid_device.id)
|
||||
await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, invalid_device.id
|
||||
)
|
||||
|
||||
|
||||
async def test_if_fires_on_button_event(hass, calls, device_reg):
|
||||
|
|
Loading…
Add table
Reference in a new issue