Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions supervisor/addons/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ATTR_DISCOVERY,
ATTR_DOCKER_API,
ATTR_ENVIRONMENT,
ATTR_FIELDS,
ATTR_FULL_ACCESS,
ATTR_GPIO,
ATTR_HASSIO_API,
Expand Down Expand Up @@ -455,6 +456,7 @@ def _migrate(config: dict[str, Any]):
{
vol.Required(ATTR_NAME): str,
vol.Optional(ATTR_DESCRIPTON): vol.Maybe(str),
vol.Optional(ATTR_FIELDS): {str: vol.Self},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite nice. I honestly didn't realize vol.Self was an option for a making a recursive schema

},
extra=vol.REMOVE_EXTRA,
)
Expand Down
1 change: 1 addition & 0 deletions supervisor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
ATTR_EXCLUDE_DATABASE = "exclude_database"
ATTR_EXTRA = "extra"
ATTR_FEATURES = "features"
ATTR_FIELDS = "fields"
ATTR_FILENAME = "filename"
ATTR_FLAGS = "flags"
ATTR_FOLDERS = "folders"
Expand Down
23 changes: 22 additions & 1 deletion tests/store/test_translation_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ def test_loading_traslations(coresys: CoreSys, tmp_path: Path):
for file in ("en.json", "es.json"):
write_json_or_yaml_file(
tmp_path / "translations" / file,
{"configuration": {"test": {"name": "test", "test": "test"}}},
{
"configuration": {
"test": {
"name": "test",
"description": "test",
"test": "test",
"fields": {"test2": {"name": "test2"}},
}
}
},
)

for file in ("no.yaml", "de.yaml"):
Expand All @@ -39,6 +48,18 @@ def test_loading_traslations(coresys: CoreSys, tmp_path: Path):
assert translations["no"]["configuration"]["test"]["name"] == "test"
assert translations["de"]["configuration"]["test"]["name"] == "test"

assert translations["en"]["configuration"]["test"]["description"] == "test"
assert translations["es"]["configuration"]["test"]["description"] == "test"

assert (
translations["en"]["configuration"]["test"]["fields"]["test2"]["name"]
== "test2"
)
assert (
translations["es"]["configuration"]["test"]["fields"]["test2"]["name"]
== "test2"
)

assert "test" not in translations["en"]["configuration"]["test"]

assert translations["no"]["network"]["80/tcp"] == "Webserver port"
Expand Down
Loading