Exemple #1
0
 def test_delete_user(self):
     # Delete existing users
     for name in ['alice', 'bob', 'charlie']:
         user = self.store.find(db.User, db.User.name == name).one()
         self.assertEqual(UserManager.delete(self.store, user.id), UserManager.SUCCESS)
     # Delete invalid UUID
     self.assertEqual(UserManager.delete(self.store, 'invalid-uuid'), UserManager.INVALID_ID)
     # Delete non-existent user
     self.assertEqual(UserManager.delete(self.store, uuid.uuid4()), UserManager.NO_SUCH_USER)
Exemple #2
0
    def test_delete_user(self):
        # Delete invalid UUID
        self.assertEqual(UserManager.delete(self.store, 'invalid-uuid'), UserManager.INVALID_ID)
        self.assertEqual(UserManager.delete(self.store, 0xfee1b4d), UserManager.INVALID_ID)
        self.assertEqual(self.store.find(db.User).count(), 3)

        # Delete non-existent user
        self.assertEqual(UserManager.delete(self.store, uuid.uuid4()), UserManager.NO_SUCH_USER)
        self.assertEqual(self.store.find(db.User).count(), 3)

        # Delete existing users
        for name in ['alice', 'bob', 'charlie']:
            user = self.store.find(db.User, db.User.name == name).one()
            self.assertEqual(UserManager.delete(self.store, user.id), UserManager.SUCCESS)
            self.assertIsNone(self.store.get(db.User, user.id))
        self.assertEqual(self.store.find(db.User).count(), 0)
Exemple #3
0
def del_user(uid):
	status = UserManager.delete(store, uid)
	if status == UserManager.SUCCESS:
		flash('Deleted user')
	else:
		flash(UserManager.error_str(status))

	return redirect(url_for('user_index'))
Exemple #4
0
def del_user(uid):
    status = UserManager.delete(store, uid)
    if status == UserManager.SUCCESS:
        flash('Deleted user')
    else:
        flash(UserManager.error_str(status))

    return redirect(url_for('user_index'))
    def test_delete_user(self):
        self.create_data()

        # Delete invalid UUID
        self.assertRaises(ValueError, UserManager.delete, "invalid-uuid")
        self.assertRaises(ValueError, UserManager.delete, 0xFEE1B4D)
        self.assertEqual(db.User.select().count(), 3)

        # Delete non-existent user
        self.assertRaises(ObjectNotFound, UserManager.delete, uuid.uuid4())
        self.assertEqual(db.User.select().count(), 3)

        # Delete existing users
        for name in ["alice", "bob", "charlie"]:
            user = db.User.get(name=name)
            UserManager.delete(user.id)
            self.assertRaises(ObjectNotFound, db.User.__getitem__, user.id)
        commit()
        self.assertEqual(db.User.select().count(), 0)
Exemple #6
0
def user_del():
    if not request.user.admin:
        return request.error_formatter(50, 'Admin restricted')

    username = request.args.get('username')
    user = store.find(User, User.name == username).one()
    if not user:
        return request.error_formatter(70, 'Unknown user')

    status = UserManager.delete(store, user.id)
    if status != UserManager.SUCCESS:
        return request.error_formatter(0, UserManager.error_str(status))

    return request.formatter({})
Exemple #7
0
def user_del():
	if not request.user.admin:
		return request.error_formatter(50, 'Admin restricted')

	username = request.args.get('username')
	user = store.find(User, User.name == username).one()
	if not user:
		return request.error_formatter(70, 'Unknown user')

	status = UserManager.delete(store, user.id)
	if status != UserManager.SUCCESS:
		return request.error_formatter(0, UserManager.error_str(status))

	return request.formatter({})