def setUpClass(cls): """ Run once before all tests """ api_key = generate_apikey() app.config['API_KEY'] = api_key app.debug = False initialize_logging(logging.INFO) # Get API key api_key = generate_apikey() app.config['API_KEY'] = api_key # Set up the test database if DATABASE_URI: app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI db.drop_all() # clean before all tests init_db()
# Create the Flask aoo app = Flask(__name__) app.config['SECRET_KEY'] = 'secret-for-dev' app.config['LOGGING_LEVEL'] = logging.INFO app.config['API_KEY'] = os.getenv('API_KEY') # Import the routes After the Flask app is created from service import service, models # Set up logging for production app.logger.propagate = False print('Setting up logging for {}...'.format(__name__)) if __name__ != '__main__': gunicorn_logger = logging.getLogger('gunicorn.error') if gunicorn_logger: app.logger.handlers = gunicorn_logger.handlers app.logger.setLevel(gunicorn_logger.level) app.logger.info(70 * '*') app.logger.info(' P E T S E R V I C E R U N N I N G '.center(70, '*')) app.logger.info(70 * '*') app.logger.info('Service inititalized!') # If an API Key was not provided, autogenerate one if not app.config['API_KEY']: app.config['API_KEY'] = service.generate_apikey() app.logger.info('Missing API Key! Autogenerated: {}'.format( app.config['API_KEY']))
def setUpClass(cls): api_key = service.generate_apikey() app.config['API_KEY'] = api_key