def user_profile(): my_token = request.args.get("token") my_uid = int(request.args.get("u_id")) response = user_utils.user_profile(my_token, my_uid) return dumps({ "email": response["email"], "name_first": response["name_first"], "name_last": response["name_last"], "handle_str": response["handle_str"] })
def test_user_profile(): storage.clear_data_store() # Get valid user's profile user = authentication.auth_register( '*****@*****.**', 'password', 'Randy', 'Random') valid_uid = user["u_id"] valid_token = user["token"] valid_profile = user_utils.user_profile(valid_token, valid_uid) assert "email" in valid_profile and valid_profile["email"] assert "name_first" in valid_profile and valid_profile["name_first"] assert "name_last" in valid_profile and valid_profile["name_last"] assert "handle_str" in valid_profile and valid_profile["handle_str"] # Get user profile with an invalid u_id invalid_uid = '-1' with pytest.raises(ValueError): user_utils.user_profile(valid_token, invalid_uid)
def get(self): # query_type:f means query freelancer, c means query client if self.is_desktop: self.user.identify = "f%s" % self.user.id if self.user.identify[0] == "f": query_type = "f" else: if self.params.get("uuid"): query_type = "f" else: query_type = "c" if query_type == "f": result = user.user_profile(self.user, self.params, self.lang) else: result = client.client_profile(self.user, self.params, self.lang) return self.send(result)
def req_user_profile(): token = request.args.get('token') u_id = int(request.args.get('u_id')) return dumps(user_profile(token, u_id))