1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-25 21:06:30 +00:00
Files
supervisor/tests/resolution/fixup/test_store_execute_reset.py
Stefan Agner f6faa18409 Bump pre-commit ruff to 0.5.7 and reformat (#5242)
It seems that the codebase is not formatted with the latest ruff
version. This PR reformats the codebase with ruff 0.5.7.
2024-08-13 20:53:56 +02:00

41 lines
1.3 KiB
Python

"""Test evaluation base."""
# pylint: disable=import-error,protected-access
from pathlib import Path
from unittest.mock import AsyncMock, 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_reset import FixupStoreExecuteReset
async def test_fixup(coresys: CoreSys, tmp_path):
"""Test fixup."""
store_execute_reset = FixupStoreExecuteReset(coresys)
test_repo = Path(tmp_path, "test_repo")
assert store_execute_reset.auto
coresys.resolution.suggestions = Suggestion(
SuggestionType.EXECUTE_RESET, ContextType.STORE, reference="test"
)
coresys.resolution.issues = Issue(
IssueType.CORRUPT_REPOSITORY, ContextType.STORE, reference="test"
)
test_repo.mkdir()
assert test_repo.exists()
mock_repositorie = AsyncMock()
mock_repositorie.git.path = test_repo
coresys.store.repositories["test"] = mock_repositorie
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))):
await store_execute_reset()
assert not test_repo.exists()
assert mock_repositorie.load.called
assert len(coresys.resolution.suggestions) == 0
assert len(coresys.resolution.issues) == 0