mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-06-23 18:36:29 +00:00

* Use the correct interface name to get properties of systemd It seems that gdbus (or systemd) automatically pick the correct interface and return the properties. However, dbussy requires the correct interface name to get all properties. * Don't expect array from Strength property The property returns a type "y" which equates to "guchar": https://developer-old.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength It seems that the old D-Bus implementation returned an array. With dbus-next a integer is returned, so no list indexing required. * Support signals and remove no longer used tests and code * Pass rauc update file path as string That is what the interface is expecting, otherwise the new lib chocks on the Pathlib type. * Support Network configuration with dbus-next Assemble Python native objects and pass them to dbus-next. Use dbus-next specific Variant class where necessary. * Use org.freedesktop.NetworkManager.Connection.Active.StateChanged org.freedesktop.NetworkManager.Connection.Active.PropertyChanged is depricated. Also it seems that StateChanged leads to fewer and more accurate signals. * Pass correct data type to RequestScan. RequestScan expects an option dictionary. Pass an empty option dictionary to it. * Update unit tests Replace gdbus specific fixtures with json files representing the return values. Those can be easily converted into native Python objects. * Rename D-Bus utils module gdbus to dbus
30 lines
991 B
Python
30 lines
991 B
Python
"""Check dbus-next implementation."""
|
|
from dbus_next.signature import Variant
|
|
|
|
from supervisor.coresys import CoreSys
|
|
from supervisor.utils.dbus import DBus, _remove_dbus_signature
|
|
|
|
|
|
def test_remove_dbus_signature():
|
|
"""Check D-Bus signature clean-up."""
|
|
test = _remove_dbus_signature(Variant("s", "Value"))
|
|
assert isinstance(test, str)
|
|
assert test == "Value"
|
|
|
|
test_dict = _remove_dbus_signature({"Key": Variant("s", "Value")})
|
|
assert isinstance(test_dict["Key"], str)
|
|
assert test_dict["Key"] == "Value"
|
|
|
|
test_dict = _remove_dbus_signature([Variant("s", "Value")])
|
|
assert isinstance(test_dict[0], str)
|
|
assert test_dict[0] == "Value"
|
|
|
|
|
|
async def test_dbus_prepare_args(coresys: CoreSys):
|
|
"""Check D-Bus dynamic argument builder."""
|
|
dbus = DBus("org.freedesktop.systemd1", "/org/freedesktop/systemd1")
|
|
signature, args = dbus._prepare_args(
|
|
True, 1, 1.0, "Value", ("a{sv}", {"Key": "Value"})
|
|
)
|
|
assert signature == "bidsa{sv}"
|