mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 20:26:29 +00:00
Fix host reload test (#3945)
This commit is contained in:
parent
f3d1904e28
commit
7c1f03932e
@ -1,6 +1,8 @@
|
||||
"""Test host manager."""
|
||||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.dbus.agent import OSAgent
|
||||
from supervisor.dbus.const import MulticastProtocolEnabled
|
||||
@ -10,21 +12,28 @@ from supervisor.dbus.systemd import Systemd
|
||||
from supervisor.dbus.timedate import TimeDate
|
||||
|
||||
|
||||
async def test_load(
|
||||
@pytest.fixture(name="coresys_dbus")
|
||||
async def fixture_coresys_dbus(
|
||||
coresys: CoreSys,
|
||||
hostname: Hostname,
|
||||
systemd: Systemd,
|
||||
timedate: TimeDate,
|
||||
os_agent: OSAgent,
|
||||
resolved: Resolved,
|
||||
dbus: list[str],
|
||||
):
|
||||
"""Test manager load."""
|
||||
) -> CoreSys:
|
||||
"""Coresys with all dbus interfaces mock loaded."""
|
||||
type(coresys.dbus).hostname = PropertyMock(return_value=hostname)
|
||||
type(coresys.dbus).systemd = PropertyMock(return_value=systemd)
|
||||
type(coresys.dbus).timedate = PropertyMock(return_value=timedate)
|
||||
type(coresys.dbus).agent = PropertyMock(return_value=os_agent)
|
||||
type(coresys.dbus).resolved = PropertyMock(return_value=resolved)
|
||||
|
||||
yield coresys
|
||||
|
||||
|
||||
async def test_load(coresys_dbus: CoreSys, dbus: list[str]):
|
||||
"""Test manager load."""
|
||||
coresys = coresys_dbus
|
||||
dbus.clear()
|
||||
|
||||
with patch.object(coresys.host.sound, "update") as sound_update:
|
||||
@ -45,10 +54,11 @@ async def test_load(
|
||||
)
|
||||
|
||||
|
||||
async def test_reload(coresys: CoreSys, dbus: list[str]):
|
||||
async def test_reload(coresys_dbus: CoreSys, dbus: list[str]):
|
||||
"""Test manager reload and ensure it does not unnecessarily recreate dbus objects."""
|
||||
await coresys.dbus.load()
|
||||
coresys = coresys_dbus
|
||||
await coresys.host.load()
|
||||
dbus.clear()
|
||||
|
||||
with patch("supervisor.utils.dbus.DBus.connect") as connect, patch.object(
|
||||
coresys.host.sound, "update"
|
||||
|
Loading…
x
Reference in New Issue
Block a user