Skip to content

Commit

Permalink
Validate area ids correct (home-assistant#165)
Browse files Browse the repository at this point in the history
* Validate that all area IDs used in fixtures are correct

* Fix Polish area name
  • Loading branch information
balloob authored Dec 28, 2022
1 parent 808d339 commit a3d667c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions script/intentfest/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/pl/_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/pl/cover_HassCloseCover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/pl/cover_HassOpenCover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a3d667c

Please sign in to comment.