Improve test coverage for zwave_js.trigger (#93260)
Improve coverage for zwave_js.trigger
This commit is contained in:
parent
5d02be5d7f
commit
d6997d8656
2 changed files with 12 additions and 8 deletions
|
@ -1,8 +1,6 @@
|
|||
"""Z-Wave JS trigger dispatcher."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import cast
|
||||
|
||||
from homeassistant.const import CONF_PLATFORM
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant
|
||||
from homeassistant.helpers.trigger import (
|
||||
|
@ -33,10 +31,7 @@ async def async_validate_trigger_config(
|
|||
) -> ConfigType:
|
||||
"""Validate config."""
|
||||
platform = _get_trigger_platform(config)
|
||||
if hasattr(platform, "async_validate_trigger_config"):
|
||||
return await platform.async_validate_trigger_config(hass, config)
|
||||
|
||||
return cast(ConfigType, platform.TRIGGER_SCHEMA(config))
|
||||
return await platform.async_validate_trigger_config(hass, config)
|
||||
|
||||
|
||||
async def async_attach_trigger(
|
||||
|
|
|
@ -10,11 +10,14 @@ from zwave_js_server.model.node import Node
|
|||
from homeassistant.components import automation
|
||||
from homeassistant.components.zwave_js import DOMAIN
|
||||
from homeassistant.components.zwave_js.helpers import get_device_id
|
||||
from homeassistant.components.zwave_js.trigger import async_validate_trigger_config
|
||||
from homeassistant.components.zwave_js.trigger import (
|
||||
_get_trigger_platform,
|
||||
async_validate_trigger_config,
|
||||
)
|
||||
from homeassistant.components.zwave_js.triggers.trigger_helpers import (
|
||||
async_bypass_dynamic_config_validation,
|
||||
)
|
||||
from homeassistant.const import SERVICE_RELOAD
|
||||
from homeassistant.const import CONF_PLATFORM, SERVICE_RELOAD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import async_get as async_get_dev_reg
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -1100,3 +1103,9 @@ async def test_zwave_js_trigger_config_entry_unloaded(
|
|||
"event": "nvm convert progress",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_get_trigger_platform_failure() -> None:
|
||||
"""Test _get_trigger_platform."""
|
||||
with pytest.raises(ValueError):
|
||||
_get_trigger_platform({CONF_PLATFORM: "zwave_js.invalid"})
|
||||
|
|
Loading…
Add table
Reference in a new issue