linux: Make test compatible with older dbusmock versions

The changes from 37b6d4b039 ("linux: Fix Bluetooth tests for
python-dbusmock changes") require a not-yet-released dbusmock version.
Simply catch the error and fall back to adding the properties in order
to be compatible with both old and new dbusmock versions of the bluez
service.
This commit is contained in:
Benjamin Berg 2022-01-27 13:08:46 +01:00
parent 50bdbe7e65
commit 94af9d6f3d

View file

@ -1745,7 +1745,11 @@ class Tests(dbusmock.DBusTestCase):
device = self.dbus_con.get_object('org.bluez', path)
if device_properties:
device.UpdateProperties(DEVICE_IFACE, device_properties)
try:
# The properties are only installed for umockdev newer than 0.25.0
device.UpdateProperties(DEVICE_IFACE, device_properties)
except dbus.exceptions.DBusException:
device.AddProperties(DEVICE_IFACE, device_properties)
battery_properties = {
'Percentage': dbus.Byte(battery_level, variant_level=1),