Ejemplo n.º 1
0
 def post(self):
     args = user_parser.parse_args()
     user = User(first_name=args.first_name, last_name=args.last_name, username=args.username, email=args.email)
     user.set_password(args.password)
     db.session.add(user)
     db.session.commit()
     user_url = fields.Url('user_bp.user_detail', absolute=True)
     user_url = user_url.output(user_url.endpoint, {"username": user.username})
     return user, 201, {"Location": user_url}
Ejemplo n.º 2
0
    def setUp(self):
        """This sets up the test case.
        It creates database and populates users table with one user.
        This user is used for testing various `users` endpoints.
        This function is executed before every single test.
        """

        db.create_all()
        user = User(first_name="Sid",
                    last_name="Yadav",
                    username="******",
                    email="*****@*****.**")
        user.set_password("password")
        db.session.add(user)
        db.session.commit()