示例#1
0
 def test_get_college_teams_1(self):
     instance = User("teacher_coll1", "../../nemesis/userman")
     teams = instance.college().teams()
     print teams
     self.assertTrue("team-ABC" in teams)
     self.assertTrue("team-DFE" in teams)
     self.assertEqual(len(teams), 2)
示例#2
0
    def test_get_college_name(self):
        instance = User("teacher_coll1", "../../nemesis/userman")
        group = instance.college()
        self.assertEqual(group.name(), "college the first")

        instance = User("teacher_coll2", "../../nemesis/userman")
        group = instance.college()
        self.assertEqual(group.name(), "secondary college")
示例#3
0
文件: app.py 项目: jmorse/nemesis
def user_details(userid):
    if handle_authentication(request.args, userid):
        user = User(userid,PATH + "/userman")
        details = user.user_details()
        full_name = details["Full name"] + " " + details["Surname"]
        email     = details["E-mail"]
        return json.dumps({"full_name":full_name, "email":email}), 200
    return '{}', 403
示例#4
0
文件: app.py 项目: jmorse/nemesis
def auth():
    if request.form.has_key("username") and request.form.has_key("password"):
        username = request.form["username"]
        password = request.form["password"]
        user = User(username, PATH + "/userman")
        if user.password_is_valid(password):
            return user.authentication_response()
        else:
            return '{"error": "invalid credentials"}', 403
    return '', 403
示例#5
0
文件: app.py 项目: jmorse/nemesis
def college_list():
    if handle_authentication(request.args):
        teacher_username = get_username(request.args["token"])
        instance = User(teacher_username, PATH + "/userman")
        college = instance.college()
        obj = {}
        obj["college_name"] = college.name()
        obj["userids"]      = college.users()
        obj["teams"]        = college.teams()
        return json.dumps(obj), 200

    return "{}", 403
示例#6
0
文件: app.py 项目: jmorse/nemesis
def register_user():
    if handle_authentication(request.form):
        teacher_username = get_username(request.form["token"])
        instance         = User(teacher_username, PATH + "/userman")
        college_group    = instance.college().group_name
        first_name       = request.form["first_name"].strip()
        last_name        = request.form["last_name"].strip()
        email            = request.form["email"].strip()
        team             = request.form["team"].strip()
        helpers.register_user(teacher_username, college_group, first_name, last_name, email, team)
        return "", 200
    return "", 403
示例#7
0
 def test_get_college_teams_2(self):
     instance = User("teacher_coll2", "../../nemesis/userman")
     teams = instance.college().teams()
     self.assertTrue("team-QWZ" in teams)
     self.assertEqual(len(teams), 1)
示例#8
0
 def test_set_user_email(self):
     instance = User("teacher_coll2","../../nemesis/userman")
     instance.conn.set_user_attribute("teacher_coll2", "mail", "*****@*****.**")
     self.assertTrue(instance.user_details()["E-mail"], "*****@*****.**")