Exemple #1
0
        rv = s.validate_password('auth_id', 'password')
        self.assertEqual(rv, 'validate_password')

        s.set_token_validator(validate_token)
        rv = s.validate_token('auth_id', 'token', 'token_ts')
        self.assertEqual(rv, 'validate_token')
    '''

    def test_extended_user(self):
        class MyUser(models.User):
            newsletter = model.BooleanProperty()
            age = model.IntegerProperty()

        auth_id = 'own:username'
        success, info = MyUser.create_user(auth_id, newsletter=True, age=22)
        self.assertTrue(success)

        app = webapp2.WSGIApplication(
            config={'webapp2_extras.auth': {
                'user_model': MyUser,
            }})
        s = auth.get_store(app=app)
        user = s.user_model.get_by_auth_id(auth_id)
        self.assertEqual(info, user)
        self.assertEqual(user.age, 22)
        self.assertTrue(user.newsletter is True)


if __name__ == '__main__':
    test_base.main()
        self.assertEqual(rv, 'validate_password')

        s.set_token_validator(validate_token)
        rv = s.validate_token('auth_id', 'token', 'token_ts')
        self.assertEqual(rv, 'validate_token')
    '''

    def test_extended_user(self):
        class MyUser(models.User):
            newsletter = model.BooleanProperty()
            age = model.IntegerProperty()

        auth_id = 'own:username'
        success, info = MyUser.create_user(auth_id, newsletter=True, age=22)
        self.assertTrue(success)

        app = webapp2.WSGIApplication(config={
            'webapp2_extras.auth': {
                'user_model': MyUser,
            }
        })
        s = auth.get_store(app=app)
        user = s.user_model.get_by_auth_id(auth_id)
        self.assertEqual(info, user)
        self.assertEqual(user.age, 22)
        self.assertTrue(user.newsletter is True)


if __name__ == '__main__':
    test_base.main()