mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 17:56:33 +00:00
No unpack variants for property sets (#3911)
This commit is contained in:
parent
2be33a80a7
commit
c0a409b25f
@ -90,9 +90,11 @@ class DBus:
|
||||
proxy_interface.path,
|
||||
)
|
||||
try:
|
||||
return await getattr(proxy_interface, method)(
|
||||
*args, unpack_variants=unpack_variants
|
||||
)
|
||||
if unpack_variants:
|
||||
return await getattr(proxy_interface, method)(
|
||||
*args, unpack_variants=True
|
||||
)
|
||||
return await getattr(proxy_interface, method)(*args)
|
||||
except DBusError as err:
|
||||
raise DBus.from_dbus_error(err)
|
||||
|
||||
@ -299,7 +301,7 @@ class DBusCallWrapper:
|
||||
|
||||
return _off_signal
|
||||
|
||||
if dbus_type in ["call", "get", "set"]:
|
||||
if dbus_type in ["call", "get"]:
|
||||
|
||||
def _method_wrapper(*args, unpack_variants: bool = True) -> Awaitable:
|
||||
return DBus.call_dbus(
|
||||
@ -308,6 +310,13 @@ class DBusCallWrapper:
|
||||
|
||||
return _method_wrapper
|
||||
|
||||
elif dbus_type == "set":
|
||||
|
||||
def _set_wrapper(*args) -> Awaitable:
|
||||
return DBus.call_dbus(self._proxy, name, *args, unpack_variants=False)
|
||||
|
||||
return _set_wrapper
|
||||
|
||||
# Didn't reach the dbus call yet, just happened to hit another interface. Return a wrapper
|
||||
return DBusCallWrapper(self.dbus, f"{self.interface}.{name}")
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Test Supervisor API."""
|
||||
# pylint: disable=protected-access
|
||||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
from aiohttp.test_utils import TestClient
|
||||
@ -114,3 +115,17 @@ async def test_api_supervisor_options_auto_update(
|
||||
assert response.status == 200
|
||||
|
||||
assert coresys.updater.auto_update is False
|
||||
|
||||
|
||||
async def test_api_supervisor_options_diagnostics(
|
||||
api_client: TestClient, coresys: CoreSys, dbus: list[str]
|
||||
):
|
||||
"""Test changing diagnostics."""
|
||||
await coresys.dbus.agent.connect(coresys.dbus.bus)
|
||||
dbus.clear()
|
||||
|
||||
response = await api_client.post("/supervisor/options", json={"diagnostics": True})
|
||||
await asyncio.sleep(0)
|
||||
|
||||
assert response.status == 200
|
||||
assert dbus == ["/io/hass/os-io.hass.os.Diagnostics"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user