Ejemplo n.º 1
0
def _load_frontend(request, _configure_application):
    '''
    Use `pytest.mark.frontend` to specify that frontend/api should be loaded
    Pass an optionnal list of modules as parameter to restrict loaded modules.

    Handle backward compatibility with Class.modules attribute too

    Properly unload themes when enabled.
    '''
    if 'app' not in request.fixturenames:
        return

    app = request.getfixturevalue('app')
    marker = request.node.get_closest_marker('frontend')
    modules = set(marker.args[0] if marker and marker.args else [])

    if getattr(request.cls, 'modules', None):
        modules |= set(request.cls.modules)

    if marker or hasattr(request.cls, 'modules'):
        from udata import frontend, api
        api.init_app(app)
        frontend.init_app(app, modules)

    if app.config['THEME'] != 'default':
        # Unload theme to allow multiple run with initialization
        from udata import theme
        with app.app_context():
            theme_module = theme.current.entrypoint.module_name

        def unload_theme():
            if theme_module in sys.modules:
                del sys.modules[theme_module]
        request.addfinalizer(unload_theme)
Ejemplo n.º 2
0
def _load_frontend(request, _configure_application):
    '''
    Use `pytest.mark.frontend` to specify that frontend/api should be loaded
    Pass an optionnal list of modules as parameter to restrict loaded modules.

    Handle backward compatibility with Class.modules attribute too

    Properly unload themes when enabled.
    '''
    if 'app' not in request.fixturenames:
        return

    app = request.getfixturevalue('app')
    marker = request.node.get_closest_marker('frontend')
    modules = set(marker.args[0] if marker and marker.args else [])

    if getattr(request.cls, 'modules', None):
        modules |= set(request.cls.modules)

    if marker or hasattr(request.cls, 'modules'):
        from udata import frontend, api
        api.init_app(app)
        frontend.init_app(app, modules)

    if app.config['THEME'] != 'default':
        # Unload theme to allow multiple run with initialization
        from udata import theme
        with app.app_context():
            theme_module = theme.current.entrypoint.module_name

        def unload_theme():
            if theme_module in sys.modules:
                del sys.modules[theme_module]
        request.addfinalizer(unload_theme)
Ejemplo n.º 3
0
def app(request):
    app = create_app(settings.Defaults, override=PiwikSettings)
    with app.app_context():
        drop_db(app)
    frontend.init_app(app, MODULES)
    with app.app_context():
        yield app
        drop_db(app)
Ejemplo n.º 4
0
def app(request):
    test_settings = get_settings(request)
    app = create_app(settings.Defaults, override=test_settings)
    app.test_client_class = TestClient

    if request.cls and hasattr(request.cls, 'modules'):
        from udata import frontend, api
        api.init_app(app)
        frontend.init_app(app, request.cls.modules)
    return app
Ejemplo n.º 5
0
def standalone(app):
    '''Factory for an all in one application'''
    from udata import api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)

    register_features(app)

    return app
Ejemplo n.º 6
0
def standalone(app):
    '''Factory for an all in one application'''
    from udata import api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)

    register_features(app)

    return app
Ejemplo n.º 7
0
def standalone(app):
    '''Factory for an all in one application'''
    from udata import admin, api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)
    # admin.init_app(app)

    from udata import ext
    ext.init_app(app)
    return app
Ejemplo n.º 8
0
Archivo: app.py Proyecto: grouan/udata
def standalone(app):
    '''Factory for an all in one application'''
    from udata import api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)

    from udata import ext
    ext.init_app(app)

    # from werkzeug.contrib.profiler import ProfilerMiddleware
    # app.config['PROFILE'] = True
    # app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])

    return app
Ejemplo n.º 9
0
def standalone(app):
    '''Factory for an all in one application'''
    from udata import api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)

    register_features(app)

    for plugin in app.config['PLUGINS']:
        name = 'udata_{0}'.format(plugin)
        plugin = import_module(name)
        if hasattr(plugin, 'init_app') and callable(plugin.init_app):
            plugin.init_app(app)

    return app
Ejemplo n.º 10
0
def standalone(app):
    '''Factory for an all in one application'''
    from udata import admin, api, core, frontend

    core.init_app(app)
    frontend.init_app(app)
    api.init_app(app)
    admin.init_app(app)

    from udata import ext
    ext.init_app(app)

    # from werkzeug.contrib.profiler import ProfilerMiddleware
    # app.config['PROFILE'] = True
    # app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])

    return app
Ejemplo n.º 11
0
def _load_frontend(request, _configure_application):
    '''
    Use `pytest.mark.frontend` to specify that frontend/api should be loaded
    Pass an optionnal list of modules as parameter to restrict loaded modules.

    Handle backward compatibility with Class.modules attribute too
    '''
    if 'app' not in request.fixturenames:
        return

    app = request.getfixturevalue('app')
    marker = request.node.get_closest_marker('frontend')
    modules = set(marker.args[0] if marker and marker.args else [])
    if getattr(request.cls, 'modules', None):
        modules |= set(request.cls.modules)

    if marker or hasattr(request.cls, 'modules'):
        from udata import frontend, api
        api.init_app(app)
        frontend.init_app(app, modules)
Ejemplo n.º 12
0
 def create_app(self):
     app = super(FrontTestCase, self).create_app()
     api.init_app(app)
     frontend.init_app(app)
     return app
Ejemplo n.º 13
0
 def create_app(self):
     app = super(SitemapTestCase, self).create_app()
     frontend.init_app(app)
     api.init_app(app)
     return app
Ejemplo n.º 14
0
 def create_app(self):
     app = super(FrontTestCase, self).create_app()
     api.init_app(app)
     frontend.init_app(app)
     return app
Ejemplo n.º 15
0
 def create_app(self):
     app = super(SitemapTestCase, self).create_app()
     frontend.init_app(app)
     api.init_app(app)
     return app
Ejemplo n.º 16
0
 def create_app(self):
     frontend.assets._named_bundles = {}  # Clear webassets bundles
     app = super(FrontTestCase, self).create_app()
     api.init_app(app)
     frontend.init_app(app)
     return app