示例#1
0
    def create_app(self):
        self.app = create_app(
            settings_override={'SQLALCHEMY_DATABASE_URI': "sqlite://"})
        self.app.config['TESTING'] = True
        self.app.config['LOGIN_DISABLED'] = False

        with self.app.app_context():
            recreate_db(db)

        self.create_oauth_credentials()
        return self.app
示例#2
0
def create_test_objects():
    if not test_objects:
        json_header = {'Content-Type': 'application/json'}
        app = create_app(
            settings_override={'SQLALCHEMY_DATABASE_URI': "sqlite://"})
        app.config['TESTING'] = True
        app.config['LOGIN_DISABLED'] = True

        with app.app_context():
            recreate_db(db)

        client = Client(**client_data())
        client._default_scopes = 'email'
        client.client_id = 'abcd'
        client.client_secret = 'abcd'
        with app.app_context():
            user = User.query.get(1)
            client.user = user
            db.session.add(client)
            db.session.commit()
        app.login_manager.init_app(app)
        app_client = app.test_client()
        rv = app_client.post('/passport/api/v1/auth/token',
                             data={
                                 'grant_type': 'client_credentials',
                                 'client_id': 'abcd',
                                 'client_secret': 'abcd',
                             })
        response = json.loads(rv.data)
        header = {
            'Authorization': 'Bearer {0}'.format(response['access_token'])
        }
        json_header.update(header)
        test_objects['header'] = header
        test_objects['json_header'] = json_header
        test_objects['app'] = app
        test_objects['client'] = app_client
    return test_objects
示例#3
0
 def setUp(self):
     self.app = create_app(
         settings_override={'SQLALCHEMY_DATABASE_URI': "sqlite://"})
     self.app.config['TESTING'] = True
示例#4
0
 def setUp(self):
     self.app = create_app()
     self.app.config['TESTING'] = True
示例#5
0
文件: test.py 项目: daveksp/passport
 def setUp(self):
     self.app = create_app()
     self.app.config['TESTING'] = True
     self.authorizer = Authorizer(self.app)