mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-15 22:10:12 +00:00
* Rename repository fixture to test_repository
Also don't remove the built-in repositories. The list was incomplete,
and tests don't seem to require that anymore.
* Get rid of StoreType
The type doesn't have much value, we have constant strings anyways.
* Introduce types.py
* Use slug to determine which repository urls to return
* Simplify BuiltinRepository enum
* Mock GitRepo load
* Improve URL handling and repository creation logic
* Refactor update_repositories
* Get rid of get_from_url
It is no longer used in production code.
* More refactoring
* Address pylint
* Introduce is_git_based property to Repository class
Return all git based URLs, including the Core repository.
* Revert "Introduce is_git_based property to Repository class"
This reverts commit dfd5ad79bf.
* Fold type.py into const.py
Align more with how Supervisor code is typically structured.
* Update supervisor/store/__init__.py
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
* Apply repository remove suggestion
* Fix tests
---------
Co-authored-by: Mike Degatano <michael.degatano@gmail.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""Test evaluation base."""
|
|
|
|
# pylint: disable=import-error,protected-access
|
|
from unittest.mock import patch
|
|
|
|
from supervisor.coresys import CoreSys
|
|
from supervisor.resolution.const import ContextType, IssueType, SuggestionType
|
|
from supervisor.resolution.data import Issue, Suggestion
|
|
from supervisor.resolution.fixups.store_execute_remove import FixupStoreExecuteRemove
|
|
from supervisor.store.repository import Repository
|
|
|
|
|
|
async def test_fixup(coresys: CoreSys, test_repository: Repository):
|
|
"""Test fixup."""
|
|
store_execute_remove = FixupStoreExecuteRemove(coresys)
|
|
|
|
assert store_execute_remove.auto is False
|
|
|
|
coresys.resolution.add_suggestion(
|
|
Suggestion(
|
|
SuggestionType.EXECUTE_REMOVE,
|
|
ContextType.STORE,
|
|
reference=test_repository.slug,
|
|
)
|
|
)
|
|
coresys.resolution.add_issue(
|
|
Issue(
|
|
IssueType.CORRUPT_REPOSITORY,
|
|
ContextType.STORE,
|
|
reference=test_repository.slug,
|
|
)
|
|
)
|
|
|
|
with patch.object(type(test_repository), "remove") as remove_repo:
|
|
await store_execute_remove()
|
|
|
|
assert remove_repo.called
|
|
|
|
assert coresys.store.save_data.called
|
|
assert len(coresys.resolution.suggestions) == 0
|
|
assert len(coresys.resolution.issues) == 0
|
|
|
|
assert test_repository.slug not in coresys.store.repositories
|