def create_user(): form = SignUpForm(request.form) if form.validate_on_submit(): if request.form.get('email') in all_users: error = Markup("<div class='alert alert-danger' role='alert'>\ <strong>User Exisits!</strong> The Email entered already exists!\ </div>") flash(error) return redirect(url_for("signup")) else: user = models.User() user.create_user(request.form.get('fullname'), request.form.get('email'), request.form.get('password')) success = Markup("<div class='alert alert-success' role='alert'>\ <strong>Done! </strong>You have successfully registered! Kindly Login\ </div>") flash(success) form_login = LoginForm() return render_template("login.html", form=form_login) return render_template("sign_up.html", form=form)
def test_more_than_one_user(self): self.user1.create_user("James Brown", "*****@*****.**", "ABC") self.user2 = models.User() self.user2.create_user("Fred Oroo", "*****@*****.**", "XYZ") count = len(models.all_users) self.assertEqual(count, 2, "Cannot create more than 1 user")
def setUp(self): self.tester = app.test_client(self) self.user1 = models.User() self.user1_bucketlist = models.Bucketlist() self.user1_bucketlist_activity = models.Bucketlist_Activities() models.all_users = {} #master user list models.all_bucketlists = {} #master bucketlist list models.all_bucketlists_activities = {} #master bucketlist activity
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False self.tester = app.test_client(self) self.user1 = models.User() models.all_users = {}