tests/dbusmock/colord: Implement FindProfileById

It's used when cleaning up profiles on race conditions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
This commit is contained in:
Jonas Ådahl 2022-09-13 18:15:37 +02:00 committed by Marge Bot
parent 8a53020e80
commit a2000a1132

View File

@ -57,6 +57,9 @@ def profile_id_from_path(mock, path):
class ColordAlreadyExistsException(dbus.DBusException): class ColordAlreadyExistsException(dbus.DBusException):
_dbus_error_name = 'org.freedesktop.ColorManager.AlreadyExists' _dbus_error_name = 'org.freedesktop.ColorManager.AlreadyExists'
class ColordNotFoundException(dbus.DBusException):
_dbus_error_name = 'org.freedesktop.ColorManager.NotFound'
@dbus.service.method(MAIN_IFACE, in_signature='ssa{sv}', out_signature='o') @dbus.service.method(MAIN_IFACE, in_signature='ssa{sv}', out_signature='o')
def CreateDevice(self, device_id, scope, props): def CreateDevice(self, device_id, scope, props):
@ -122,6 +125,14 @@ def DeleteProfile(self, profile_path):
self.EmitSignal(MAIN_IFACE, 'ProfileRemoved', 'o', [profile_path]) self.EmitSignal(MAIN_IFACE, 'ProfileRemoved', 'o', [profile_path])
@dbus.service.method(MAIN_IFACE, in_signature='s', out_signature='o')
def FindProfileById(self, profile_id):
if profile_id in self.devices:
return self.devices[profile_id]
else:
raise ColordNotFoundException()
@dbus.service.method(MOCK_IFACE) @dbus.service.method(MOCK_IFACE)
def Reset(self): def Reset(self):
for device_path in self.devices.values(): for device_path in self.devices.values():