From a2000a1132e45225e634b540deddd522063dee48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Sep 2022 18:15:37 +0200 Subject: [PATCH] tests/dbusmock/colord: Implement FindProfileById It's used when cleaning up profiles on race conditions. Part-of: --- src/tests/dbusmock-templates/colord.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tests/dbusmock-templates/colord.py b/src/tests/dbusmock-templates/colord.py index 30b7faa10..d81f33780 100644 --- a/src/tests/dbusmock-templates/colord.py +++ b/src/tests/dbusmock-templates/colord.py @@ -57,6 +57,9 @@ def profile_id_from_path(mock, path): class ColordAlreadyExistsException(dbus.DBusException): _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') def CreateDevice(self, device_id, scope, props): @@ -122,6 +125,14 @@ def DeleteProfile(self, 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) def Reset(self): for device_path in self.devices.values():