Files
supervisor/tests/resolution/evaluation/test_evaluate_operating_system.py
Stefan Agner 3be0c13fc5 Drop Debian 12 from supported OS list (#6337)
* Drop Debian 12 from supported OS list

With the deprecation of Home Assistant Supervised installation method
Debian 12 is no longer supported. This change removes Debian 12
from the list of supported operating systems in the evaluation logic.

* Improve tests
2025-11-24 11:46:23 +01:00

53 lines
1.8 KiB
Python

"""Test evaluation base."""
# pylint: disable=import-error,protected-access
from unittest.mock import MagicMock, patch
from supervisor.const import CoreState
from supervisor.coresys import CoreSys
from supervisor.resolution.evaluations.operating_system import EvaluateOperatingSystem
async def test_evaluation(coresys: CoreSys):
"""Test evaluation."""
operating_system = EvaluateOperatingSystem(coresys)
await coresys.core.set_state(CoreState.SETUP)
assert operating_system.reason not in coresys.resolution.unsupported
coresys.host._info = MagicMock(
operating_system="unsupported", timezone=None, timezone_tzinfo=None
)
await operating_system()
assert operating_system.reason in coresys.resolution.unsupported
coresys.os._available = True
assert coresys.os.available
await operating_system()
assert operating_system.reason not in coresys.resolution.unsupported
async def test_did_run(coresys: CoreSys):
"""Test that the evaluation ran as expected."""
operating_system = EvaluateOperatingSystem(coresys)
should_run = operating_system.states
should_not_run = [state for state in CoreState if state not in should_run]
assert len(should_run) != 0
assert len(should_not_run) != 0
with patch(
"supervisor.resolution.evaluations.operating_system.EvaluateOperatingSystem.evaluate",
return_value=None,
) as evaluate:
for state in should_run:
await coresys.core.set_state(state)
await operating_system()
evaluate.assert_called_once()
evaluate.reset_mock()
for state in should_not_run:
await coresys.core.set_state(state)
await operating_system()
evaluate.assert_not_called()
evaluate.reset_mock()