Add selectors for text and arbitrary objects (#45112)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Thomas Lovén 2021-01-27 09:20:19 +01:00 committed by GitHub
parent 6800f4b6fd
commit 06ade6129c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View file

@ -162,3 +162,17 @@ class ActionSelector(Selector):
"""Selector of an action sequence (script syntax).""" """Selector of an action sequence (script syntax)."""
CONFIG_SCHEMA = vol.Schema({}) CONFIG_SCHEMA = vol.Schema({})
@SELECTORS.register("object")
class ObjectSelector(Selector):
"""Selector for an arbitrary object."""
CONFIG_SCHEMA = vol.Schema({})
@SELECTORS.register("text")
class StringSelector(Selector):
"""Selector for a multi-line text string."""
CONFIG_SCHEMA = vol.Schema({vol.Optional("multiline", default=False): bool})

View file

@ -169,3 +169,21 @@ def test_target_selector_schema(schema):
def test_action_selector_schema(schema): def test_action_selector_schema(schema):
"""Test action sequence selector.""" """Test action sequence selector."""
selector.validate_selector({"action": schema}) selector.validate_selector({"action": schema})
@pytest.mark.parametrize(
"schema",
({},),
)
def test_object_selector_schema(schema):
"""Test object selector."""
selector.validate_selector({"object": schema})
@pytest.mark.parametrize(
"schema",
({}, {"multiline": True}, {"multiline": False}),
)
def test_text_selector_schema(schema):
"""Test text selector."""
selector.validate_selector({"text": schema})