Warn for old slugs/entity ids (#20478)
* Warn for old slugs/entity ids * add comments * Lint * LInt * Lint * Lint
This commit is contained in:
parent
38b1ce3fe0
commit
87316c4e83
3 changed files with 92 additions and 1 deletions
|
@ -602,3 +602,31 @@ def test_comp_entity_ids():
|
|||
for invalid in (['light.kitchen', 'not-entity-id'], '*', ''):
|
||||
with pytest.raises(vol.Invalid):
|
||||
schema(invalid)
|
||||
|
||||
|
||||
def test_schema_with_slug_keys_allows_old_slugs(caplog):
|
||||
"""Test schema with slug keys allowing old slugs."""
|
||||
schema = cv.schema_with_slug_keys(str)
|
||||
|
||||
with patch.dict(cv.INVALID_SLUGS_FOUND, clear=True):
|
||||
for value in ('_world', 'wow__yeah'):
|
||||
caplog.clear()
|
||||
# Will raise if not allowing old slugs
|
||||
schema({value: 'yo'})
|
||||
assert "Found invalid slug {}".format(value) in caplog.text
|
||||
|
||||
assert len(cv.INVALID_SLUGS_FOUND) == 2
|
||||
|
||||
|
||||
def test_entity_id_allow_old_validation(caplog):
|
||||
"""Test schema allowing old entity_ids."""
|
||||
schema = vol.Schema(cv.entity_id)
|
||||
|
||||
with patch.dict(cv.INVALID_ENTITY_IDS_FOUND, clear=True):
|
||||
for value in ('hello.__world', 'great.wow__yeah'):
|
||||
caplog.clear()
|
||||
# Will raise if not allowing old entity ID
|
||||
schema(value)
|
||||
assert "Found invalid entity_id {}".format(value) in caplog.text
|
||||
|
||||
assert len(cv.INVALID_ENTITY_IDS_FOUND) == 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue