def register(): form = RegisterForm() if request.method == 'POST': if form.validate_on_submit(): if User.query.filter(User.email == form.email.data).count() > 0: form.email.errors.append("Email address already in use.") return view('register', form) user = User( name=form.name.data, email=form.email.data, password=form.password.data, phone_number="+{0}{1}".format(form.country_code.data, form.phone_number.data), area_code=str(form.phone_number.data)[0:3]) db.session.add(user) db.session.commit() login_user(user, remember=True) return redirect_to('home') else: return view('register', form) return view('register', form)
def register(): form = RegisterForm() if request.method == "POST": if form.validate_on_submit(): if User.query.filter(User.email == form.email.data).count() > 0: form.email.errors.append("Email address already in use.") return view("register", form) user = User( name=form.name.data, email=form.email.data, password=form.password.data, phone_number="+{0}{1}".format(form.country_code.data, form.phone_number.data), ) db.session.add(user) db.session.commit() login_user(user, remember=True) return redirect_to("home") else: return view("register", form) return view("register", form)
def test_populate_register_form_with_missing_params_should_produce_error( self): form = RegisterForm(name='Name') assert form.validate() is False
def test_populate_register_form_with_missing_params_should_produce_error(self): form = RegisterForm(name='Name') assert form.validate() is False