示例#1
0
def put_user(user_id, dbsrv=dbsrv):
    """A PUT request to users will update some combination of
    name, email, and admin status."""
    try:
        args = request.get_json()
        name = args.get('name')
        email = args.get('email')
        admin = args.get('admin')
        # this is only needed if we are changing admin status
        group_id = args.get('group_id')
    except:
        raise err.JSONParseError("JSON Parsing Failed.")

    if name is not None or email is not None:
        dbsrv.change_user(user_id,
                          name=name,
                          email=email)
    if admin is not None and group_id is not None:
        dbsrv.set_admin(user_id, group_id, bool(admin))
    return make_response("", 200)
示例#2
0
 def test_fails_if_user_does_not_exist(self):
     dbsrv.change_user(4, name="test")
示例#3
0
 def test_succeeds_normally(self):
     dbsrv.change_user(1, name="test", email="*****@*****.**")
     assert self.james.name == "test"
     assert self.james.email == "*****@*****.**"