From 8a53020e80660cedc46b4d9a5a160d6d0589e439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Sep 2022 18:14:04 +0200 Subject: [PATCH] tests/dbusmoc/colord: Return proper AlreadyExists error for profiles This matches what colord does, and allows us to rely on checking error codes both in production and in the test suite. Part-of: --- src/tests/dbusmock-templates/colord.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/tests/dbusmock-templates/colord.py b/src/tests/dbusmock-templates/colord.py index f51d06579..30b7faa10 100644 --- a/src/tests/dbusmock-templates/colord.py +++ b/src/tests/dbusmock-templates/colord.py @@ -53,6 +53,11 @@ def profile_id_from_path(mock, path): return profile_id return None + +class ColordAlreadyExistsException(dbus.DBusException): + _dbus_error_name = 'org.freedesktop.ColorManager.AlreadyExists' + + @dbus.service.method(MAIN_IFACE, in_signature='ssa{sv}', out_signature='o') def CreateDevice(self, device_id, scope, props): uid = os.getuid() @@ -93,6 +98,10 @@ def CreateProfileWithFd(self, profile_id, scope, handle, props): profile_path = PATH_PREFIX + '/profiles/' + \ escape_unit_name(profile_id) + \ '_' + username + '_' + str(uid) + + if profile_id in self.profiles: + raise ColordAlreadyExistsException() + self.profiles[profile_id] = profile_path self.AddObject(profile_path, PROFILE_IFACE,