Files
supervisor/tests/store/test_validate.py
Stefan Agner 9491b1ff89 Avoid reordering add-on repositories on Backup load (#5595)
* Avoid reordering add-on repositories on Backup load

The `ensure_builtin_repositories` function uses a set to deduplicate
items, which sometimes led to a change of order in elements. This is
problematic when deduplicating Backups.

Simply avoid mangling the list of add-on repositories on load. Instead
rely on `update_repositories` which uses the same function to ensure
built-in repositories when loading the store configuration and restoring
a backup file.

* Update tests

* ruff format

* ruff check

* ruff check fixes

* ruff format

* Update tests/store/test_validate.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Simplify test

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-01-31 12:10:47 -05:00

25 lines
666 B
Python

"""Test schema validation."""
import pytest
from voluptuous import Invalid
from supervisor.store.validate import repositories
@pytest.mark.parametrize(
"repo_list,valid",
[
(["core", "local"], True),
(["https://github.com/hassio-addons/repository"], True),
(["not_a_url"], False),
(["https://fail.com/duplicate", "https://fail.com/duplicate"], False),
],
)
async def test_repository_validate(repo_list: list[str], valid: bool):
"""Test repository list validate."""
if valid:
assert repositories(repo_list) == repo_list
else:
with pytest.raises(Invalid):
repositories(repo_list)