def setUp(self): self.app = create_app() self.app.testing = True self.app.config['SECRET_KEY'] = 'testing' self.app.config['SRP_USER_AGENT_EMAIL'] = '*****@*****.**' self.app.config['WTF_CSRF_ENABLED'] = False if 'DB' in env: # Default is an in-memroy SQLite database self.app.config['SQLALCHEMY_DATABASE_URI'] = env['DB'] db.create_all(app=self.app)
def setUp(self): config = { 'SECRET_KEY': 'testing', 'SRP_USER_AGENT_EMAIL': '*****@*****.**', 'WTF_CSRF_ENABLED': False, } # Default to an ephemeral SQLite DB for testing unless given another # database to connect to. config['SQLALCHEMY_DATABASE_URI'] = env.get('DB', 'sqlite:///') self.app = create_app(config) db.create_all(app=self.app)
#!/usr/bin/env python import os.path from evesrp import create_app app = create_app(instance_path=os.path.abspath(os.path.dirname(__file__))) if __name__ == '__main__': app.run()
def configure_from_env(app): # Configure Brave Core if all the needed things are there try: core_private_key = hex2key(environ['CORE_AUTH_PRIVATE_KEY']) core_public_key = hex2key(environ['CORE_AUTH_PUBLIC_KEY']) core_identifier = environ['CORE_AUTH_IDENTIFIER'] except KeyError: pass else: app.config['SRP_AUTH_METHODS'].append(BraveCore(core_private_key, core_public_key, core_identifier)) secret_key = environ.get('SECRET_KEY') if secret_key is not None: app.config['SECRET_KEY'] = unhexlify(secret_key) config_path = os.path.join(os.path.abspath(os.getcwd()), 'config.py') app = create_app(config_path) configure_from_env(app) if __name__ == '__main__': # So we get the database tables for these from evesrp.auth.testauth import TestUser, TestGroup from evesrp.auth.bravecore import CoreUser, CoreGroup print("Creating databases...") app.extensions['sqlalchemy'].db.create_all(app=app)