def test_creation_with_existing_username(self):
        self.flush([self.insert_user("larry", "*****@*****.**", "larry")])
        self.assertEqual(1, UserData.all().count())
        self.assertEqual("larry", UserData.all()[0].user_id)
        self.assertEqual("larry", UserData.all()[0].username)

        self.assertTrue(self.insert_user("larry2", "*****@*****.**",
            "larry") is None)
    def test_creation_with_existing_username(self):
        self.flush([self.insert_user("larry", "*****@*****.**", "larry")])
        self.assertEqual(1, UserData.all().count())
        self.assertEqual("larry", UserData.all()[0].user_id)
        self.assertEqual("larry", UserData.all()[0].username)

        self.assertTrue(
            self.insert_user("larry2", "*****@*****.**", "larry") is None)
 def test_creation_with_password(self):
     self.flush([
         self.insert_user("larry", "*****@*****.**", "larry", "Password1")
     ])
     self.assertEqual(1, UserData.all().count())
     retrieved = UserData.all()[0]
     self.assertEqual("larry", retrieved.user_id)
     self.assertTrue(retrieved.validate_password("Password1"))
     self.assertFalse(retrieved.validate_password("Password2"))
 def test_creation_with_password(self):
     self.flush([self.insert_user("larry",
                                  "*****@*****.**",
                                  "larry",
                                  "Password1")])
     self.assertEqual(1, UserData.all().count())
     retrieved = UserData.all()[0]
     self.assertEqual("larry", retrieved.user_id)
     self.assertTrue(retrieved.validate_password("Password1"))
     self.assertFalse(retrieved.validate_password("Password2"))
    def test_creation_without_username(self):
        added = [
            self.insert_user("larry", "*****@*****.**"),
            self.insert_user("curly", "*****@*****.**"),
            self.insert_user("moe", "*****@*****.**"),
        ]
        # We don't care about consistency policy issues - we just want proper
        # counts and such.
        self.flush(added)
        self.assertEqual(3, UserData.all().count())
        self.assertEqual(set(["larry", "curly", "moe"]),
                         set(user.user_id for user in UserData.all()))

        # "Re-adding" moe doesn't duplicate.
        self.flush([self.insert_user("moe", "*****@*****.**")])
        self.assertEqual(3, UserData.all().count())
    def test_creation_without_username(self):
        added = [
            self.insert_user("larry", "*****@*****.**"),
            self.insert_user("curly", "*****@*****.**"),
            self.insert_user("moe", "*****@*****.**"),
        ]
        # We don't care about consistency policy issues - we just want proper
        # counts and such.
        self.flush(added)
        self.assertEqual(3, UserData.all().count())
        self.assertEqual(set(["larry", "curly", "moe"]),
                         set(user.user_id for user in UserData.all()))

        # "Re-adding" moe doesn't duplicate.
        self.flush([self.insert_user("moe", "*****@*****.**")])
        self.assertEqual(3, UserData.all().count())
Beispiel #7
0
    def get(self):
        developers = UserData.all()
        developers.filter('developer = ', True).fetch(1000)
        template_values = {
            "developers": developers,
            "selected_id": "devs",
        }

        self.render_jinja2_template('devpanel/devs.html', template_values)
Beispiel #8
0
    def get(self):
        developers = UserData.all()
        developers.filter('developer = ', True).fetch(1000)
        template_values = { 
            "developers": developers,
            "selected_id": "devs",
        }

        self.render_jinja2_template('devpanel/devs.html', template_values) 
Beispiel #9
0
def get_coaches_all_students():
    users = UserData.all()
    coaches_dict = {}
    for user in users:
        for coach in user.coaches:
            if not coach in coaches_dict:
                coaches_dict[coach] = [user.user_email]
            else:
                coaches_dict[coach].append(user.user_email)
    return coaches_dict
Beispiel #10
0
def get_coaches_all_students():
    users = UserData.all()
    coaches_dict = {}
    for user in users:
        for coach in user.coaches:
            if not coach in coaches_dict:
                coaches_dict[coach] = [user.user_email]
            else:
                coaches_dict[coach].append(user.user_email)
    return coaches_dict
Beispiel #11
0
def get_coaches_students_count():
    coaches_dict = get_coaches_all_students()
    coaches_list = []
    for coach_email, students_list in coaches_dict.items():
        coach = UserData.all().filter("user_email = ", coach_email).get()
        if coach:
            coach_dict = {
                "joined": str(coach.joined),
                "last_activity": str(coach.last_activity),
                "coach_email": coach_email,
                "number_of_students": len(students_list)
            }
            coaches_list.append(coach_dict)
    return coaches_list
Beispiel #12
0
def get_coaches_students_count():
    coaches_dict = get_coaches_all_students()
    coaches_list = []
    for coach_email, students_list in coaches_dict.items():
        coach = UserData.all().filter("user_email = ", coach_email).get()
        if coach:
            coach_dict = { 
                            "joined": str(coach.joined),
                            "last_activity": str(coach.last_activity),
                            "coach_email": coach_email,
                            "number_of_students": len(students_list)
                         }
            coaches_list.append(coach_dict)
    return coaches_list
Beispiel #13
0
def main(db_filename):
    """Start a dev_appserver, create db entries on it, and exit."""
    try:
       with open(db_filename): 
           filename=db_filename
    except IOError:
           filename=None
    handler_test_utils.start_dev_appserver(db=filename)
    try:
        stub()

        from user_models import UserData
        import csv
        if filename == None:
            print >>sys.stderr, 'Making users'
            Users()
            print >>sys.stderr, 'Making users:Done'

        users = UserData.all().fetch(100)
        with open('users.csv', 'wb') as csvfile:
            spamwriter = csv.writer(csvfile, delimiter=' ',
                                    quotechar='|', quoting=csv.QUOTE_MINIMAL)
            for u in users:
                print u.nickname
                spamwriter.writerow([u.nickname])

        print >>sys.stderr, 'Done!  Output in %s' % db_filename

        if filename == None:
            shutil.copy(os.path.join(handler_test_utils.tmpdir,
                                 'datastore', 'test.sqlite'),
                        db_filename)

    finally:
        # We keep around the tmpdir for debugging/etc
        handler_test_utils.stop_dev_appserver(delete_tmpdir=False)