diff --git a/custom_components/hacs/utils/validate.py b/custom_components/hacs/utils/validate.py index 52a00322877..c0ba455c9c5 100644 --- a/custom_components/hacs/utils/validate.py +++ b/custom_components/hacs/utils/validate.py @@ -45,9 +45,9 @@ def _country_validator(values) -> list[str]: vol.Optional("content_in_root"): bool, vol.Optional("country"): _country_validator, vol.Optional("filename"): str, - vol.Optional("hacs"): vol.Coerce(AwesomeVersion), + vol.Optional("hacs"): str, vol.Optional("hide_default_branch"): bool, - vol.Optional("homeassistant"): vol.Coerce(AwesomeVersion), + vol.Optional("homeassistant"): str, vol.Optional("persistent_directory"): str, vol.Optional("render_readme"): bool, vol.Optional("zip_release"): bool, diff --git a/custom_components/hacs/validate/hacsjson.py b/custom_components/hacs/validate/hacsjson.py index b025a49ed82..4d000075bee 100644 --- a/custom_components/hacs/validate/hacsjson.py +++ b/custom_components/hacs/validate/hacsjson.py @@ -1,9 +1,10 @@ from __future__ import annotations from voluptuous.error import Invalid +from voluptuous.humanize import humanize_error from ..enums import HacsCategory, RepositoryFile -from ..repositories.base import HacsRepository +from ..repositories.base import HacsManifest, HacsRepository from ..utils.validate import HACS_MANIFEST_JSON_SCHEMA from .base import ActionValidationBase, ValidationException @@ -25,10 +26,10 @@ async def async_validate(self): content = await self.repository.async_get_hacs_json(self.repository.ref) try: - HACS_MANIFEST_JSON_SCHEMA(content) + hacsjson = HacsManifest.from_dict(HACS_MANIFEST_JSON_SCHEMA(content)) except Invalid as exception: - raise ValidationException(exception) from exception + raise ValidationException(humanize_error(content, exception)) from exception if self.repository.data.category == HacsCategory.INTEGRATION: - if content.get("zip_release") and not content.get("filename"): + if hacsjson.zip_release and not hacsjson.filename: raise ValidationException("zip_release is True, but filename is not set") diff --git a/tests/common.py b/tests/common.py index 9c3b0b60f29..7cf64ec471e 100644 --- a/tests/common.py +++ b/tests/common.py @@ -21,7 +21,7 @@ import homeassistant.util.dt as date_util from homeassistant.util.unit_system import METRIC_SYSTEM -from custom_components.hacs.repositories.base import HacsRepository +from custom_components.hacs.repositories.base import HacsManifest, HacsRepository from custom_components.hacs.utils.logger import LOGGER from tests.async_mock import AsyncMock, Mock, patch @@ -65,6 +65,7 @@ def dummy_repository_base(hacs, repository=None): repository.integration_manifest = {"config_flow": False, "domain": "test"} repository.data.published_tags = ["1", "2", "3"] repository.data.update_data(fixture("repository_data.json", asjson=True)) + repository.hacs_manifest = HacsManifest.from_dict({}) async def update_repository(*args, **kwargs): pass diff --git a/tests/validate/test_hacsjson_check.py b/tests/validate/test_hacsjson_check.py index 60e05baa631..2cfe1a8c9c1 100644 --- a/tests/validate/test_hacsjson_check.py +++ b/tests/validate/test_hacsjson_check.py @@ -1,6 +1,7 @@ from aiogithubapi.objects.repository.content import AIOGitHubAPIRepositoryTreeContent import pytest +from custom_components.hacs.repositories.base import HacsManifest from custom_components.hacs.validate.hacsjson import Validator @@ -57,7 +58,7 @@ async def test_hacs_manifest_with_missing_filename(repository, caplog): repository.data.category = "integration" async def _async_get_hacs_json(_): - return {"name": "test", "zip_release": True} + return {"name": "test", "zip_release": True, "hacs": "0.0.0"} repository.async_get_hacs_json = _async_get_hacs_json