1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 12:29:08 +00:00

Use session dbus mocks for all tests (#4198)

* Use session dbus mocks for all tests

* func instead of fn for pylint
This commit is contained in:
Mike Degatano
2023-03-21 02:30:31 -04:00
committed by GitHub
parent c6ddc8e427
commit a6caccd845
157 changed files with 685 additions and 6572 deletions

View File

@@ -1,19 +1,21 @@
"""Test fixup system reboot."""
from unittest.mock import PropertyMock, patch
from supervisor.coresys import CoreSys
from supervisor.host.const import HostFeature
from supervisor.host.manager import HostManager
from supervisor.resolution.const import ContextType, IssueType, SuggestionType
from supervisor.resolution.data import Issue, Suggestion
from supervisor.resolution.fixups.system_execute_reboot import FixupSystemExecuteReboot
from tests.dbus_service_mocks.base import DBusServiceMock
from tests.dbus_service_mocks.logind import Logind as LogindService
async def test_fixup(coresys: CoreSys, dbus: list[str]):
async def test_fixup(
coresys: CoreSys,
all_dbus_services: dict[str, DBusServiceMock | dict[str, DBusServiceMock]],
):
"""Test fixup."""
await coresys.dbus.logind.connect(coresys.dbus.bus)
dbus.clear()
logind_service: LogindService = all_dbus_services["logind"]
logind_service.Reboot.calls.clear()
system_execute_reboot = FixupSystemExecuteReboot(coresys)
assert system_execute_reboot.auto is False
@@ -23,11 +25,8 @@ async def test_fixup(coresys: CoreSys, dbus: list[str]):
)
coresys.resolution.issues = Issue(IssueType.REBOOT_REQUIRED, ContextType.SYSTEM)
with patch.object(
HostManager, "features", new=PropertyMock(return_value=[HostFeature.REBOOT])
):
await system_execute_reboot()
await system_execute_reboot()
assert dbus == ["/org/freedesktop/login1-org.freedesktop.login1.Manager.Reboot"]
assert logind_service.Reboot.calls == [(False,)]
assert len(coresys.resolution.suggestions) == 0
assert len(coresys.resolution.issues) == 0