def app(): _app = create_app(TestConfig) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import subprocess from flask.ext.script import Manager, Shell, Server from flask.ext.migrate import MigrateCommand from dci_notify.app import create_app from dci_notify.user.models import User from dci_notify.settings import DevConfig, ProdConfig from dci_notify.database import db if os.environ.get("DCI_NOTIFY_ENV") == 'prod': app = create_app(ProdConfig) print('Manager app created with ProdConfig') else: app = create_app(DevConfig) print('Manager app created with DevConfig') manager = Manager(app) TEST_CMD = 'foreman run py.test tests' @manager.command def test(): """Run the tests.""" os.environ['DCI_NOTIFY_ENV'] = 'test' status = subprocess.call(TEST_CMD, shell=True) sys.exit(status)
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import subprocess from flask.ext.script import Manager, Shell, Server from flask.ext.migrate import MigrateCommand from dci_notify.app import create_app from dci_notify.user.models import User from dci_notify.settings import DevConfig, ProdConfig from dci_notify.database import db if os.environ.get("DCI_NOTIFY_ENV") == 'prod': app = create_app(ProdConfig) print('Manager app created with ProdConfig') else: app = create_app(DevConfig) print('Manager app created with DevConfig') manager = Manager(app) TEST_CMD = 'foreman run py.test tests' @manager.command def test(): """Run the tests.""" os.environ['DCI_NOTIFY_ENV'] = 'test' status = subprocess.call(TEST_CMD, shell=True) sys.exit(status)
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
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