Fix other enums in helpers (#71505)

This commit is contained in:
Paulus Schoutsen 2022-05-07 20:57:48 -07:00 committed by GitHub
parent 00291fb1a6
commit e35a5a1a28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -704,7 +704,9 @@ class SelectSelector(Selector):
vol.Required("options"): vol.All(vol.Any([str], [select_option])),
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("custom_value", default=False): cv.boolean,
vol.Optional("mode"): vol.Coerce(SelectSelectorMode),
vol.Optional("mode"): vol.All(
vol.Coerce(SelectSelectorMode), lambda val: val.value
),
}
)
@ -827,7 +829,9 @@ class TextSelector(Selector):
vol.Optional("suffix"): str,
# The "type" controls the input field in the browser, the resulting
# data can be any string so we don't validate it.
vol.Optional("type"): vol.Coerce(TextSelectorType),
vol.Optional("type"): vol.All(
vol.Coerce(TextSelectorType), lambda val: val.value
),
}
)

View file

@ -351,7 +351,7 @@ def test_object_selector_schema(schema, valid_selections, invalid_selections):
(
({}, ("abc123",), (None,)),
({"multiline": True}, (), ()),
({"multiline": False}, (), ()),
({"multiline": False, "type": "email"}, (), ()),
),
)
def test_text_selector_schema(schema, valid_selections, invalid_selections):
@ -402,7 +402,7 @@ def test_text_selector_schema(schema, valid_selections, invalid_selections):
(0, None, ["red"]),
),
(
{"options": [], "custom_value": True, "multiple": True},
{"options": [], "custom_value": True, "multiple": True, "mode": "list"},
(["red"], ["green", "blue"], []),
(0, None, "red"),
),