def POST(self): if (web.config._session.roleid != 1): raise web.seeother('/') pdata = web.input(uname=None, action=None) if pdata.action == "create": users.add_user(pdata.uname, pdata.utype, pdata.pword) elif pdata.action == "modify": users.modify_user(pdata.uname, pdata.utype) elif pdata.action == 'delete': users.del_user(pdata.uname) raise web.seeother('/manager')
def test_modify_user(user): ''' Test each aspect of modify_user ''' # Refuse to modify non existant users assert not users.modify_user(*user) users.add_user(*user) # Sucessfully modify a user assert users.modify_user(*user) # Refuse users breaking requirements assert not users.modify_user(*user[:2], '*' * 31, user[3]) assert not users.modify_user(*user[:3], '*' * 101)
def test_modify_user(db): assert users.add_user( ("test1", "*****@*****.**", "tester", "one"), db) is True assert users.modify_user("test1", "*****@*****.**", "tester", "one", db) is True assert users.modify_user("user_id_not_in_db", "*****@*****.**", "tester", "me", db) is False assert users.search_user("test1", db) == { 'id': 1, 'NAME': 'tester', 'EMAIL': '*****@*****.**', 'USER_ID': 'test1', 'LASTNAME': 'one' }
def update_user(user_id, email, user_name, user_last_name, db): ''' Requirements: - Returns False if there any errors. - Otherwise, it returns True. ''' return users.modify_user(user_id, email, user_name, user_last_name, db)
def update_user(user_id, email, user_name, user_last_name): ''' Updates the values of an existing user Requirements: - Returns False if there any errors. - Otherwise, it returns True. ''' logger.info('Updating an User') return users.modify_user(user_id, email, user_name, user_last_name)