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>
This commit is contained in:
parent
3aecb1c262
commit
8a53020e80
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user