def app(request, tmpdir):
    templates_path = tmpdir.ensure_dir('templates')
    backgrounds_path = Path(tmpdir.ensure_dir('backgrounds'))
    custom_uploads_path = Path(tmpdir.ensure_dir('custom_uploads'))
    thumb_path = Path(tmpdir.ensure_dir('thumbnails'))
    crop_path = Path(tmpdir.ensure_dir('crops'))
    printouts_path = Path(tmpdir.ensure_dir('printouts'))
    logos_path = Path(tmpdir.ensure_dir('logos'))

    test_config = {
        'SECRET_KEY': 'test',
        'ASSETS_DEBUG': True,
        'TESTING': True,
        'SQLALCHEMY_DATABASE_URI': 'sqlite://',
        'UPLOADED_BACKGROUNDS_DEST': backgrounds_path,
        'UPLOADED_CUSTOM_DEST': custom_uploads_path,
        'UPLOADED_PRINTOUTS_DEST': printouts_path,
        'UPLOADED_THUMBNAIL_DEST': thumb_path,
        'UPLOADED_CROP_DEST': crop_path,
        'MEDIA_THUMBNAIL_FOLDER': thumb_path,
        'UPLOADED_LOGOS_DEST': logos_path,
        'MEDIA_FOLDER': Path(tmpdir),
        'HOSTNAME': 'http://meetings.edw.ro/',
        'DEFAULT_MAIL_SENDER': 'noreply',
        'TEMPLATES_PATH': templates_path,
        'MAIL_SUPPRESS_SEND': True,
        'TRANSLATIONS': _TRANSLATIONS,
        'BLUEPRINTS': (
            'aewa_extra_views',
            'cites_extra_views',
        )
    }

    app = create_app(test_config)
    app_context = app.app_context()
    app_context.push()
    app.jinja_loader = jinja2.ChoiceLoader(
        [app.jinja_loader,
         jinja2.FileSystemLoader([str(templates_path)])])

    db.create_all()

    app.client = app.test_client()

    @request.addfinalizer
    def fin():
        app_context.pop()
        tmpdir.remove(rec=1)

    return app
def app(request, tmpdir):
    templates_path = tmpdir.ensure_dir('templates')
    backgrounds_path = path(tmpdir.ensure_dir('backgrounds'))
    custom_uploads_path = path(tmpdir.ensure_dir('custom_uploads'))
    thumb_path = path(tmpdir.ensure_dir('thumbnails'))
    crop_path = path(tmpdir.ensure_dir('crops'))
    printouts_path = path(tmpdir.ensure_dir('printouts'))
    logos_path = path(tmpdir.ensure_dir('logos'))

    test_config = {
        'SECRET_KEY': 'test',
        'ASSETS_DEBUG': True,
        'TESTING': True,
        'SQLALCHEMY_DATABASE_URI': 'sqlite://',
        'UPLOADED_BACKGROUNDS_DEST': backgrounds_path,
        'UPLOADED_CUSTOM_DEST': custom_uploads_path,
        'UPLOADED_PRINTOUTS_DEST': printouts_path,
        'UPLOADED_THUMBNAIL_DEST': thumb_path,
        'UPLOADED_CROP_DEST': crop_path,
        'MEDIA_THUMBNAIL_FOLDER': thumb_path,
        'UPLOADED_LOGOS_DEST': logos_path,
        'MEDIA_FOLDER': path(tmpdir),
        'HOSTNAME': 'http://meetings.edw.ro/',
        'DEFAULT_MAIL_SENDER': 'noreply',
        'TEMPLATES_PATH': templates_path,
        'MAIL_SUPPRESS_SEND': True,
        'TRANSLATIONS': _TRANSLATIONS,
    }

    app = create_app(test_config)
    app_context = app.app_context()
    app_context.push()
    app.jinja_loader = jinja2.ChoiceLoader([
        app.jinja_loader,
        jinja2.FileSystemLoader([str(templates_path)])
    ])

    db.create_all()

    app.client = app.test_client()

    @request.addfinalizer
    def fin():
        app_context.pop()
        tmpdir.remove(rec=1)

    return app
Example #3
0
from mrt.app import create_app

app = create_app()
#!/usr/bin/env python

from click import CommandCollection
from mrt.app import create_app
from mrt.manager import cli as manager_cli
from contrib.importer import cli as importer_cli


app = create_app()


if __name__ == '__main__':
    cli = CommandCollection(sources=[manager_cli, importer_cli])
    cli(obj={'app': app})