def testFetch(self):
     user = UserData(username='******', password='******')
     user.put()
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username, "Found user: "******"Found user_id: " + str(actual.user_id))
 def testSave(self):
     user = UserData(username='******', password='******')
     new_user = self.user_datastore.save(user)
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username, "Found user: " + str(actual.username))
     self.assertTrue(new_user.user_id ==1, 'New user_id: ' + str(new_user.user_id))
Exemplo n.º 3
0
 def testFetchByUsername_NotFound(self):
     user1 = UserData(username='******', password='******')
     self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     self.user_datastore.save(user2)
     userfound1 = self.user_datastore.fetchByUsername('foo')
     self.assertTrue(userfound1 == None, 'Found user' + str(userfound1))
Exemplo n.º 4
0
 def testSave(self):
     user = UserData(username='******', password='******')
     new_user = self.user_datastore.save(user)
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username,
                       "Found user: " + str(actual.username))
     self.assertTrue(new_user.user_id == 1,
                     'New user_id: ' + str(new_user.user_id))
Exemplo n.º 5
0
 def testFetch(self):
     user = UserData(username='******', password='******')
     user.put()
     user_id = user.key().id()
     actual = self.user_datastore.fetch(user_id)
     self.assertEquals(user.username, actual.username,
                       "Found user: "******"Found user_id: " + str(actual.user_id))
Exemplo n.º 6
0
 def testFetchByUsername(self):
     user1 = UserData(username='******', password='******')
     self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     self.user_datastore.save(user2)
     userfound1 = self.user_datastore.fetchByUsername('cdoremus1')
     self.assertEquals(userfound1.password, user1.password,
                       'Found user' + str(userfound1))
     self.assertTrue(userfound1.user_id == 1,
                     "User id is not 1: " + str(userfound1.user_id))
 def testLogin(self):
     username = '******'
     password = '******'
     hashed_password = self.crypt.crypt_password(username, password)
     user = UserData(username=username, password=hashed_password)
     self.storage.save(user)
     user_id = user.key().id()
     cookie = self.crypt.make_cookie(user_id)
     new_cookie = self.service.login(username, password, cookie)
     self.assertFalse(new_cookie == None)
     self.assertEquals(user.key().id(), 1)
Exemplo n.º 8
0
 def testFetchAll(self):
     user1 = UserData(username='******', password='******')
     new_user1 = self.user_datastore.save(user1)
     user2 = UserData(username='******', password='******')
     new_user2 = self.user_datastore.save(user2)
     users = self.user_datastore.fetchAll()
     self.assertTrue(users.count() == 2,
                     "User count: " + str(users.count()))
     self.assertTrue(new_user1.user_id == 1,
                     'New user_id for user1: ' + str(new_user1.user_id))
     self.assertTrue(new_user2.user_id == 2,
                     'New user_id for user2: ' + str(new_user2.user_id))
 def testLogin_Failed(self):
     username = '******'
     password = '******'
     hashed_password = self.crypt.crypt_password(username, password)
     user = UserData(username=username, password=hashed_password)
     self.storage.save(user)
     user_id = user.key().id()
     cookie = self.crypt.make_cookie(user_id)
     try: 
         self.service.login(username + 'foo', password, cookie)
         self.fail('Should not get here because LoginError should be raised due to bad usernames')
     except LoginError as error:
         self.assertEquals(error.validation_messages['login_error'], 'Invalid login')
         print error
Exemplo n.º 10
0
 def register(self, username, password, verify, email=None):
     validation_msgs, isValid = self.signup_validation.validate(
         username=username, password=password, verify=verify, email=email)
     if not isValid:
         raise UserRegistrationError(validation_msgs)
     else:
         crypt_password = self._crypt_password(username, password)
         user = UserData(username=username,
                         password=crypt_password,
                         email=email)
         saved_user = self.storage.save(user)
         user_id = saved_user.key().id()
     return self.crypt.make_cookie(user_id)
Exemplo n.º 11
0
    def fetch(self, user_id):
        user = UserData.get_by_id(user_id)
        user.user_id = user.key().id()

        return user