Skip to content

Commit

Permalink
refactor: LDAP backend tolerates double deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Apr 28, 2024
1 parent 867de91 commit 69b565e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion canaille/backends/ldap/ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,7 @@ def save(self):

def delete(self):
conn = Backend.get().connection
conn.delete_s(self.dn)
try:
conn.delete_s(self.dn)
except ldap.NO_SUCH_OBJECT:
pass
2 changes: 2 additions & 0 deletions tests/backends/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def test_model_lifecycle(testclient, backend):
assert not models.User.query(id=user.id)
assert not models.User.get(id=user.id)

user.delete()


def test_model_attribute_edition(testclient, backend):
user = models.User(
Expand Down

0 comments on commit 69b565e

Please sign in to comment.