device: Throw a NoEnrolledPrints error if trying to delete a device with no prints

Adjust tests accordingly
This commit is contained in:
Marco Trevisan (Treviño)
2021-01-27 22:47:09 +01:00
parent 4b246d3ce2
commit 6f355797f8
4 changed files with 45 additions and 46 deletions

View File

@ -184,6 +184,11 @@ def DeleteEnrolledFingers2(device):
raise dbus.exceptions.DBusException(
'Device was not claimed before use',
name='net.reactivated.Fprint.Error.ClaimDevice')
if not device.fingers[device.claimed_user]:
raise dbus.exceptions.DBusException(
'No enrolled prints in device {} for user {}'.format(device.path,
device.claimed_user),
name='net.reactivated.Fprint.Error.NoEnrolledPrints')
device.fingers[device.claimed_user] = []
@dbus.service.method(DEVICE_IFACE,