Add domain key config validation (#104242)
* Drop use of regex in helpers.extract_domain_configs * Update test * Revert test update * Add domain_from_config_key helper * Add validator * Address review comment * Update snapshots * Inline domain_from_config_key in validator
This commit is contained in:
parent
25bea91683
commit
3bcc6194ef
19 changed files with 144 additions and 9 deletions
|
@ -1631,3 +1631,19 @@ def test_platform_only_schema(
|
|||
cv.platform_only_config_schema("test_domain")({"test_domain": {"foo": "bar"}})
|
||||
assert expected_message in caplog.text
|
||||
assert issue_registry.async_get_issue(HOMEASSISTANT_DOMAIN, expected_issue)
|
||||
|
||||
|
||||
def test_domain() -> None:
|
||||
"""Test domain."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
cv.domain_key(5)
|
||||
with pytest.raises(vol.Invalid):
|
||||
cv.domain_key("")
|
||||
with pytest.raises(vol.Invalid):
|
||||
cv.domain_key("hue ")
|
||||
with pytest.raises(vol.Invalid):
|
||||
cv.domain_key("hue ")
|
||||
assert cv.domain_key("hue") == "hue"
|
||||
assert cv.domain_key("hue1") == "hue1"
|
||||
assert cv.domain_key("hue 1") == "hue"
|
||||
assert cv.domain_key("hue 1") == "hue"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue