mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
Fix FK errors when deleting a user
This commit is contained in:
parent
724f04726e
commit
ad688a23c3
@ -37,12 +37,12 @@ class UserManager:
|
||||
@staticmethod
|
||||
def delete(uid):
|
||||
user = UserManager.get(uid)
|
||||
user.delete_instance()
|
||||
user.delete_instance(recursive=True)
|
||||
|
||||
@staticmethod
|
||||
def delete_by_name(name):
|
||||
user = User.get(name=name)
|
||||
user.delete_instance()
|
||||
user.delete_instance(recursive=True)
|
||||
|
||||
@staticmethod
|
||||
def try_auth(name, password):
|
||||
|
@ -104,6 +104,7 @@ class UserManagerTestCase(unittest.TestCase):
|
||||
# Delete existing users
|
||||
for name in ["alice", "bob", "charlie"]:
|
||||
user = db.User.get(name=name)
|
||||
db.ClientPrefs.create(user=user, client_name="tests") # test for FK handling
|
||||
UserManager.delete(user.id)
|
||||
self.assertRaises(db.User.DoesNotExist, db.User.__getitem__, user.id)
|
||||
self.assertEqual(db.User.select().count(), 0)
|
||||
@ -113,6 +114,8 @@ class UserManagerTestCase(unittest.TestCase):
|
||||
|
||||
# Delete existing users
|
||||
for name in ["alice", "bob", "charlie"]:
|
||||
user = db.User.get(name=name)
|
||||
db.ClientPrefs.create(user=user, client_name="tests") # test for FK handling
|
||||
UserManager.delete_by_name(name)
|
||||
self.assertFalse(db.User.select().where(db.User.name == name).exists())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user