Allow github requirements specs in hassfest for non-core integrations (#124925)
* allow all requirements specs * remove unnecessary tests * Revert "remove unnecessary tests" This reverts commit0a2af0318d
. * Revert "allow all requirements specs" This reverts commitd15cd27f7b
. * be lenient only for custom integrations * don't allow blanks as requested --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
3d43c22485
commit
72065768f3
2 changed files with 32 additions and 12 deletions
|
@ -84,18 +84,19 @@ def validate_requirements_format(integration: Integration) -> bool:
|
|||
if not version:
|
||||
continue
|
||||
|
||||
for part in version.split(";", 1)[0].split(","):
|
||||
version_part = PIP_VERSION_RANGE_SEPARATOR.match(part)
|
||||
if (
|
||||
version_part
|
||||
and AwesomeVersion(version_part.group(2)).strategy
|
||||
== AwesomeVersionStrategy.UNKNOWN
|
||||
):
|
||||
integration.add_error(
|
||||
"requirements",
|
||||
f"Unable to parse package version ({version}) for {pkg}.",
|
||||
)
|
||||
continue
|
||||
if integration.core:
|
||||
for part in version.split(";", 1)[0].split(","):
|
||||
version_part = PIP_VERSION_RANGE_SEPARATOR.match(part)
|
||||
if (
|
||||
version_part
|
||||
and AwesomeVersion(version_part.group(2)).strategy
|
||||
== AwesomeVersionStrategy.UNKNOWN
|
||||
):
|
||||
integration.add_error(
|
||||
"requirements",
|
||||
f"Unable to parse package version ({version}) for {pkg}.",
|
||||
)
|
||||
continue
|
||||
|
||||
return len(integration.errors) == start_errors
|
||||
|
||||
|
|
|
@ -87,3 +87,22 @@ def test_validate_requirements_format_successful(integration: Integration) -> No
|
|||
]
|
||||
assert validate_requirements_format(integration)
|
||||
assert len(integration.errors) == 0
|
||||
|
||||
|
||||
def test_validate_requirements_format_github_core(integration: Integration) -> None:
|
||||
"""Test requirement that points to github fails with core component."""
|
||||
integration.manifest["requirements"] = [
|
||||
"git+https://github.com/user/project.git@1.2.3",
|
||||
]
|
||||
assert not validate_requirements_format(integration)
|
||||
assert len(integration.errors) == 1
|
||||
|
||||
|
||||
def test_validate_requirements_format_github_custom(integration: Integration) -> None:
|
||||
"""Test requirement that points to github succeeds with custom component."""
|
||||
integration.manifest["requirements"] = [
|
||||
"git+https://github.com/user/project.git@1.2.3",
|
||||
]
|
||||
integration.path = Path("")
|
||||
assert validate_requirements_format(integration)
|
||||
assert len(integration.errors) == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue