def app(): os.makedirs(config.STORAGE_CONTAINER) _app = create_app(config) with _app.app_context(): _db.create_all() ctx = _app.test_request_context() ctx.push() yield _app _db.drop_all() shutil.rmtree(config.STORAGE_CONTAINER) ctx.pop()
def app(): os.makedirs(config.STORAGE_CONTAINER) _app = create_app(config) with _app.app_context(): _db.create_all() ctx = _app.test_request_context() ctx.push() yield _app _db.drop_all() shutil.rmtree(config.STORAGE_CONTAINER) ctx.pop()
from vwadaptor.settings import DevConfig, ProdConfig from vwadaptor.app import create_app from vwadaptor.extensions import db if os.environ.get("VWADAPTOR_ENV") == 'prod': config = ProdConfig else: config = DevConfig '''This is a temporary fix for allowing docker-compose to work. As docker-copose doesn't have any mechanism yet for health check of dependent services This is the only way to wait for postgres and any other container(swift perhaps) to start ''' time.sleep(15) app = create_app(config) @app.before_first_request def create_db(): #db.drop_all() db.create_all() from flask_jwt import jwt_required,current_identity @app.route('/testjwt',methods=['GET']) @jwt_required() def test(): return "You are: %s" % current_identity.email
import time from vwadaptor.settings import DevConfig, ProdConfig from vwadaptor.app import create_app from vwadaptor.extensions import db if os.environ.get("VWADAPTOR_ENV") == 'prod': config = ProdConfig else: config = DevConfig '''This is a temporary fix for allowing docker-compose to work. As docker-copose doesn't have any mechanism yet for health check of dependent services This is the only way to wait for postgres and any other container(swift perhaps) to start ''' time.sleep(15) app = create_app(config) @app.before_first_request def create_db(): #db.drop_all() db.create_all() from flask_jwt import jwt_required, current_identity @app.route('/testjwt', methods=['GET']) @jwt_required() def test(): return "You are: %s" % current_identity.email
def test_production_config(): app = create_app(ProdConfig) assert app.config['ENV'] == 'prod' assert app.config['DEBUG'] is False assert app.config['DEBUG_TB_ENABLED'] is False assert app.config['ASSETS_DEBUG'] is False
def test_dev_config(): app = create_app(DevConfig) assert app.config['ENV'] == 'dev' assert app.config['DEBUG'] is True assert app.config['ASSETS_DEBUG'] is True