Beispiel #1
0
 def test_get_user(self):
     login = {'name': 'Marc', 'email': '*****@*****.**'}
     queries.register_user(login)
     self.assertTrue(queries.get_user("Marc"))
     queries.delete_User('Marc')
     self.assertFalse(queries.get_user(None))
     self.assertFalse(queries.get_user("1234"))
     self.assertFalse(queries.get_user(""))
     self.assertFalse(queries.get_user(" "))
Beispiel #2
0
 def test_register_user(self):
     login = {'name': 'Marc', 'email': '*****@*****.**'}
     self.assertTrue(queries.register_user(login))
     queries.delete_User('Marc')
     login['name'] = None
     self.assertFalse(queries.register_user(login))
     login['name'] = ""
     self.assertFalse(queries.register_user(login))
     #login['name'] = " "
     #self.assertFalse(queries.register_user(login))
     self.assertFalse(queries.register_user("Marc"))
Beispiel #3
0
def test_all_sql():
    foo = get_questions("preps")
    print(type(foo))

    bar = get_questions("gender")
    print(getsizeof(bar))

    register_user("derek2", "pppoo")
    register_user("anni5", "dogs")
    print(search_users("derek2")["u_id"])
    print(
        search_users("derek2")["reg_date"],
        type(search_users("derek2")["reg_date"]))

    update_gradebook(1, 100, 1)  # new_user_record(ru_id, rq_id, correct)
    update_gradebook(1, 100, 0)  # update_exsisting(r_id, correct)
    update_gradebook(2, 100, 0)
    update_gradebook(1, 100, 1)
    print(grades_for(1)[0]["rq_id"])
    print(profile_table(1)[0]["qinfo_1"])
Beispiel #4
0
def register():
    if request.method == "POST":
        session.clear()
        if not request.form.get("username"):
            return apology("must provide username", 403)
        elif not request.form.get("password"):
            return apology("must provide password", 403)
        elif request.form.get("password") != request.form.get("repeat"):
            return apology("passwords must match", 403)

        user = register_user(request.form.get("username"),
                             request.form.get("password"))
        if user:
            session["user_id"] = user["u_id"]
            session["username"] = user["username"]
            session["reg_date"] = user["reg_date"].strftime("%B %dth, %Y")
            flash(f"{user.username} registered and logged in!")
            return redirect("/")
        else:
            flash("Username taken")
            return redirect("/register")

    else:
        return render_template("register.html")
Beispiel #5
0
 def test_delete_user(self):
     self.assertEqual(queries.delete_User(None), None)
     self.assertEqual(queries.delete_User("Tom"), "User not found.")
     login = {'name': 'Marc', 'email': '*****@*****.**'}
     queries.register_user(login)
     self.assertEqual(queries.delete_User('Marc'), "user deleted")
Beispiel #6
0
def route_save_registration():
    queries.register_user(request.form['new_name'])
    return redirect('/')