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
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
def setUp(self): self.app = create_app( settings_override={'SQLALCHEMY_DATABASE_URI': "sqlite://"}) self.app.config['TESTING'] = True
def setUp(self): self.app = create_app() self.app.config['TESTING'] = True
def setUp(self): self.app = create_app() self.app.config['TESTING'] = True self.authorizer = Authorizer(self.app)