def testUserRegisterShortPasswordLength(self): # Scenario with short password form = RegisterForm(email='*****@*****.**', username='******', password='******', confirm='abc') self.assertFalse(form.validate())
def testUserRegister(self): # Scenario with correct user data form = RegisterForm(email='*****@*****.**', username='******', password='******', confirm='StrongPassword') self.assertTrue(form.validate())
def testUserRegisterPasswordDoesNotMatch(self): # Scenario with non-matching user password form = RegisterForm(email='*****@*****.**', username='******', password='******', confirm='strongpassword') self.assertFalse(form.validate())
def register(): form = RegisterForm() if form.validate_on_submit(): users = User(username=form.username.data, title=form.title.data, first_name=form.first_name.data, last_name=form.last_name.data, other_name=form.other_names.data, password=form.password.data, phone=form.phone.data, email=form.email.data, address=form.address.data, region=form.regions.data, district=form.district.data, subdistrict=form.subdistrict.data, village=form.village.data, role=form.roles.data, activation='', active=True, created_date=datetime.datetime.utcnow(), last_login=datetime.datetime.utcnow(), retries=0, picture="Default") db.session.add(users) db.session.commit() usr = User.query.filter_by(username=form.username.data).first() flash('Thank you for registering, Continue from your account', 'success') login_user(usr) return redirect(url_for("user.members")) return render_template("gstheme/register.html", rform=form)
def test_validate_success_register_form(self): # Ensure correct data validates. form = RegisterForm( email='*****@*****.**', password='******', confirm='example', last_name='example', name='example') self.assertTrue(form.validate())
def register(): form = RegisterForm(request.form) form.expiration_month.choices = MONTHS form.expiration_year.choices = [(str(year), year) for year in (range(2015, 2026))] if form.validate_on_submit(): user = User(email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() amount = 500 customer = stripe.Customer.create(email=user.email, card=request.form['stripeToken']) try: charge = stripe.Charge.create(customer=customer.id, amount=amount, currency='usd', description='Flask Charge') if charge: User.query.filter_by(email=user.email).update(dict(paid=True)) db.session.commit() login_user(user) flash('Thanks for paying!', 'success') return redirect(url_for('user.members')) except stripe.CardError: flash('Oops. Something is wrong with your card info!', 'danger') return redirect(url_for('user.register')) return render_template('user/register.html', form=form, key=stripe_keys['stripe_publishable_key'])
def testEmailAlreadyRegistered(self): # Scenario with attempt to register using already registered email address form = RegisterForm(email='*****@*****.**', username='******', password='******', confirm='admin_user') self.assertFalse(form.validate())
def register(): form = RegisterForm() if form.validate_on_submit(): users = User( username=form.username.data, title=form.title.data, first_name=form.first_name.data, last_name=form.last_name.data, other_name=form.other_names.data, password=form.password.data, phone=form.phone.data, email=form.email.data, address=form.address.data, region=form.regions.data, district=form.district.data, subdistrict=form.subdistrict.data, village=form.village.data, role=form.roles.data, activation="", active=True, created_date=datetime.datetime.utcnow(), last_login=datetime.datetime.utcnow(), retries=0, picture="Default", ) db.session.add(users) db.session.commit() usr = User.query.filter_by(username=form.username.data).first() flash("Thank you for registering, Continue from your account", "success") login_user(usr) return redirect(url_for("user.members")) return render_template("gstheme/register.html", rform=form)
def test_validate_email_already_registered(self): # Ensure user can't register when a duplicate email is used form = RegisterForm( email='*****@*****.**', password='******', confirm='just_a_test_user' ) self.assertFalse(form.validate())
def test_validate_email_already_registered(self): # Ensure user can't register when a duplicate email is used form = RegisterForm( email='*****@*****.**', password='******', confirm='admin_user' ) self.assertFalse(form.validate())
def test_validate_email_already_registered(self): # Ensure user can't register when a duplicate email is used form = RegisterForm( email='*****@*****.**', password='******', confirm='admin_user', last_name='admin', name='admin' ) self.assertFalse(form.validate())
def test_check_success_register_form(self): """ Test that correct data lets a user register """ form = RegisterForm(email='*****@*****.**', password='******', first_name='test', last_name='test', confirm='example') self.assertTrue(form.validate())
def test_check_invalid_password_format(self): """ Test Check that incorrect data does not let a user register """ form = RegisterForm(first_name='test', last_name='test', email='*****@*****.**', password='******', confirm='wrong') self.assertFalse(form.validate())
def test_check_email_already_registered(self): """ Tests that user can't register with a email that is already being used """ form = RegisterForm(first_name='test', last_name='test', email='*****@*****.**', password='******', confirm='just_a_test_user') self.assertFalse(form.validate())
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): user = User(email=form.email.data, password=form.password.data) db.session.add(user) db.session.commit() login_user(user) flash('Thank you for registering.', 'success') return redirect(url_for("user.members")) return render_template('user/register.html', form=form)
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): user = User( email=form.email.data, password=form.password.data ) db.session.add(user) db.session.commit() login_user(user) flash('Thank you for registering.', 'success') return redirect(url_for("user.members")) return render_template('user/register.html', form=form)
def register(): form = RegisterForm(request.form) if request.method == "POST": user = UserHandler.register(form) if user: flash.info('Welcome "{}".'.format(user.username)) return redirect(request.args.get('next', url_for('app.home'))) return render_template('user/register.html', form=form)
def register(): form = RegisterForm(request.form) form.expiration_month.choices = MONTHS form.expiration_year.choices = [ (str(year), year) for year in (range(2015, 2026))] if form.validate_on_submit(): user = User( email=form.email.data, password=form.password.data ) db.session.add(user) db.session.commit() amount = 500 customer = stripe.Customer.create( email=user.email, card=request.form['stripeToken'] ) try: charge = stripe.Charge.create( customer=customer.id, amount=amount, currency='usd', description='Flask Charge' ) if charge: User.query.filter_by( email=user.email).update(dict(paid=True)) db.session.commit() login_user(user) flash('Thanks for paying!', 'success') return redirect(url_for('user.members')) except stripe.CardError: flash('Oops. Something is wrong with your card info!', 'danger') return redirect(url_for('user.register')) return render_template( 'user/register.html', form=form, key=stripe_keys['stripe_publishable_key'])
def test_validate_invalid_password_format(self): # Ensure incorrect data does not validate. form = RegisterForm( email='*****@*****.**', password='******', confirm='') self.assertFalse(form.validate())
def test_validate_success_register_form(self): # Ensure correct data validates. form = RegisterForm( email='*****@*****.**', password='******', confirm='example') self.assertTrue(form.validate())