Пример #1
0
def test_dev_config():
    """
    Development config.
    """
    app = create_app(DevConfig)
    assert app.config["ENV"] == "dev"
    assert app.config["DEBUG"] is True
Пример #2
0
def create_megaqc_app():
    from megaqc.app import create_app
    from megaqc.settings import DevConfig, ProdConfig, TestConfig

    if env.bool("FLASK_DEBUG", False):
        CONFIG = DevConfig()
    elif env.bool("MEGAQC_PRODUCTION", False):
        CONFIG = ProdConfig()
    else:
        CONFIG = TestConfig()

    if settings.run_db_check:
        # Attempt to connect to the database exists to check that it exists
        try:
            dbengine = sqlalchemy.create_engine(
                CONFIG.SQLALCHEMY_DATABASE_URI).connect()
            metadata = sqlalchemy.MetaData(dbengine, reflect=True)
            assert "sample_data" in metadata.tables
        except:
            print(
                "\n##### ERROR! Could not find table 'sample_data' in database!"
            )
            print(
                "Has the database been initialised? If not, please run 'megaqc initdb' first"
            )
            print("Exiting...\n")
            sys.exit(1)
        else:
            dbengine.close()

    return create_app(CONFIG)
Пример #3
0
def test_production_config():
    """
    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
Пример #4
0
def app():
    """An application for the tests."""
    _app = create_app(TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    yield _app

    ctx.pop()
Пример #5
0
def app():
    """An application for the tests."""
    config = TestConfig()
    init_db(config.SQLALCHEMY_DATABASE_URI)
    _app = create_app(config)
    ctx = _app.test_request_context()
    ctx.push()

    yield _app

    ctx.pop()
Пример #6
0
def create_megaqc_app(info):
    import os
    from megaqc.app import create_app
    from megaqc.settings import TestConfig, DevConfig, ProdConfig

    if os.environ.get("FLASK_DEBUG", False):
        CONFIG = DevConfig()
    elif os.environ.get("MEGAQC_PRODUCTION", False):
        CONFIG = ProdConfig()
    else:
        CONFIG = TestConfig()
    return create_app(CONFIG)
Пример #7
0
import os
from megaqc.app import create_app
from megaqc.settings import TestConfig, DevConfig, ProdConfig

CONFIG = TestConfig()
if os.environ.get('MEGAQC_DEBUG', False):
    CONFIG = DevConfig()
elif os.environ.get('MEGAQC_PRODUCTION', False):
    CONFIG = ProdConfig()

app = create_app(CONFIG)
Пример #8
0
def test_production_config():
    """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
Пример #9
0
def test_dev_config():
    """Development config."""
    app = create_app(DevConfig)
    assert app.config['ENV'] == 'dev'
    assert app.config['DEBUG'] is True