[mutter] tests/dbusmoc/colord: Return proper AlreadyExists error for profiles



commit 8a53020e80660cedc46b4d9a5a160d6d0589e439
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Sep 13 18:14:04 2022 +0200

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>

 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 f51d065792..30b7faa10b 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]