1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00
Files
supervisor/tests/resolution/fixup/test_fixup.py
Mike Degatano 6ef4f3cc67 Add blockbuster library and find I/O from unit tests (#5731)
* Add blockbuster library and find I/O from unit tests

* Fix lint and test issue

* Fixes from feedback

* Avoid modifying webapp object in executor

* Split su options validation and only validate timezone on change
2025-03-06 16:40:13 -05:00

50 lines
1.7 KiB
Python

"""Test check."""
# pylint: disable=import-error, protected-access
from unittest.mock import AsyncMock, patch
from supervisor.const import CoreState
from supervisor.coresys import CoreSys
from supervisor.resolution.const import ContextType, SuggestionType
from supervisor.resolution.data import Suggestion
from supervisor.resolution.validate import get_valid_modules
async def test_check_autofix(coresys: CoreSys):
"""Test check for setup."""
await coresys.core.set_state(CoreState.RUNNING)
coresys.resolution.fixup._fixups[
"system_create_full_backup"
].process_fixup = AsyncMock()
with patch(
"supervisor.resolution.fixups.system_create_full_backup.FixupSystemCreateFullBackup.auto",
return_value=True,
):
await coresys.resolution.fixup.run_autofix()
coresys.resolution.fixup._fixups[
"system_create_full_backup"
].process_fixup.assert_not_called()
coresys.resolution.suggestions = Suggestion(
SuggestionType.CREATE_FULL_BACKUP, ContextType.SYSTEM
)
with patch(
"supervisor.resolution.fixups.system_create_full_backup.FixupSystemCreateFullBackup.auto",
return_value=True,
):
await coresys.resolution.fixup.run_autofix()
coresys.resolution.fixup._fixups[
"system_create_full_backup"
].process_fixup.assert_called_once()
assert len(coresys.resolution.suggestions) == 0
async def test_dynamic_fixup_loader(coresys: CoreSys):
"""Test dynamic fixup loader, this ensures that all fixups have defined a setup function."""
for fixup in await coresys.run_in_executor(get_valid_modules, "fixups"):
assert fixup in coresys.resolution.fixup._fixups