From a3d667c07cfb4c7ba65a1577eca8f24c6c79cee4 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 27 Dec 2022 22:05:39 -0500 Subject: [PATCH] Validate area ids correct (#165) * Validate that all area IDs used in fixtures are correct * Fix Polish area name --- script/intentfest/validate.py | 6 ++++++ tests/pl/_fixtures.yaml | 4 ++-- tests/pl/cover_HassCloseCover.yaml | 4 ++-- tests/pl/cover_HassOpenCover.yaml | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/script/intentfest/validate.py b/script/intentfest/validate.py index e1593f2649..20cba9be6e 100644 --- a/script/intentfest/validate.py +++ b/script/intentfest/validate.py @@ -324,6 +324,12 @@ def validate_language(intent_schemas, language, errors): content = _load_yaml_file(errors[language], language, test_file, schema) if content is None or test_file.name == "_fixtures.yaml": + area_ids = set(area["id"] for area in content.get("areas", [])) + for entity in content.get("entities", []): + if entity["area"] not in area_ids: + errors[language].append( + f"{path}: Entity {entity['name']} references unknown area {entity['id']}" + ) continue if test_file.name not in sentence_files: diff --git a/tests/pl/_fixtures.yaml b/tests/pl/_fixtures.yaml index dd874202ce..7ea8bdb0ef 100644 --- a/tests/pl/_fixtures.yaml +++ b/tests/pl/_fixtures.yaml @@ -19,5 +19,5 @@ entities: id: fan.ceiling area: living_room - name: Szuflad(a|ę) - id: cover.cloth - area: woonkamer + id: cover.szuflada + area: living_room diff --git a/tests/pl/cover_HassCloseCover.yaml b/tests/pl/cover_HassCloseCover.yaml index 6b235a58ab..39ec98c759 100644 --- a/tests/pl/cover_HassCloseCover.yaml +++ b/tests/pl/cover_HassCloseCover.yaml @@ -5,13 +5,13 @@ tests: intent: name: "HassCloseCover" slots: - name: cover.cloth + name: cover.szuflada - sentences: - "Zamknij szufladę w salonie" intent: name: "HassCloseCover" slots: - name: cover.cloth + name: cover.szuflada area: living_room - sentences: diff --git a/tests/pl/cover_HassOpenCover.yaml b/tests/pl/cover_HassOpenCover.yaml index 7b6a9dd6fb..0ddb8c8ec3 100644 --- a/tests/pl/cover_HassOpenCover.yaml +++ b/tests/pl/cover_HassOpenCover.yaml @@ -5,13 +5,13 @@ tests: intent: name: "HassOpenCover" slots: - name: cover.cloth + name: cover.szuflada - sentences: - "Otwórz szufladę w salonie" intent: name: "HassOpenCover" slots: - name: cover.cloth + name: cover.szuflada area: living_room - sentences: