supervisor/tests/resolution/test_check.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

23 lines
779 B
Python

"""Test checks."""
from unittest.mock import Mock, patch
from supervisor.const import CoreState
from supervisor.coresys import CoreSys
from supervisor.resolution.checks.core_security import CheckCoreSecurity
from supervisor.utils import check_exception_chain
async def test_check_system_error(coresys: CoreSys, capture_exception: Mock):
"""Test error while checking system."""
coresys.core.state = CoreState.STARTUP
with (
patch.object(CheckCoreSecurity, "run_check", side_effect=ValueError),
patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0**3))),
):
await coresys.resolution.check.check_system()
capture_exception.assert_called_once()
assert check_exception_chain(capture_exception.call_args[0][0], ValueError)