Exemple #1
0
def iter_suites(packages=None):
    """Yield all testsuites."""
    from werkzeug.utils import import_string, find_modules
    from flask_registry import ModuleAutoDiscoveryRegistry, \
        ImportPathRegistry

    app = create_app()

    if packages is None:
        testsuite = ModuleAutoDiscoveryRegistry('testsuite', app=app)
        from invenio import testsuite as testsuite_invenio
        testsuite.register(testsuite_invenio)
    else:
        exclude = map(lambda x: x + '.testsuite',
                      app.config.get('PACKAGES_EXCLUDE', []))
        testsuite = ImportPathRegistry(initial=packages, exclude=exclude,
                                       load_modules=True)

    for package in testsuite:
        for name in find_modules(package.__name__):
            module = import_string(name)
            if not module.__name__.split('.')[-1].startswith('test_'):
                continue
            if hasattr(module, 'TEST_SUITE'):
                yield module.TEST_SUITE
            else:
                app.logger.warning(
                    "%s: No test suite defined." % module.__name__)
Exemple #2
0
def main():
    from invenio_base.factory import create_app
    app = create_app()
    manager.app = app
    if len(sys.argv) < 2 or sys.argv[1] != 'dbexec':
        sys.argv.insert(1, 'dbexec')
    manager.run()
def main():
    """Run manager."""
    from invenio_base.factory import create_app

    app = create_app()
    manager.app = app
    manager.run()
Exemple #4
0
def iter_suites(packages=None):
    """Yield all testsuites."""
    from werkzeug.utils import import_string, find_modules
    from flask_registry import ModuleAutoDiscoveryRegistry, \
        ImportPathRegistry

    app = create_app()

    if packages is None:
        testsuite = ModuleAutoDiscoveryRegistry('testsuite', app=app)
        from invenio import testsuite as testsuite_invenio
        testsuite.register(testsuite_invenio)
    else:
        exclude = map(lambda x: x + '.testsuite',
                      app.config.get('PACKAGES_EXCLUDE', []))
        testsuite = ImportPathRegistry(initial=packages,
                                       exclude=exclude,
                                       load_modules=True)

    for package in testsuite:
        for name in find_modules(package.__name__):
            module = import_string(name)
            if not module.__name__.split('.')[-1].startswith('test_'):
                continue
            if hasattr(module, 'TEST_SUITE'):
                yield module.TEST_SUITE
            else:
                app.logger.warning("%s: No test suite defined." %
                                   module.__name__)
Exemple #5
0
def setup(sphinx):
    """Setup Sphinx object."""
    from flask import has_app_context
    from invenio_base.factory import create_app

    if not has_app_context():
        app = create_app()
        ctx = app.test_request_context('/')
        ctx.push()
Exemple #6
0
def setup(sphinx):
    """Setup Sphinx object."""
    from flask import has_app_context
    from invenio_base.factory import create_app

    if not has_app_context():
        app = create_app()
        ctx = app.test_request_context('/')
        ctx.push()
Exemple #7
0
def setup(sphinx):
    """Setup Sphinx object."""
    from flask import has_app_context
    from invenio_base.factory import create_app
    PACKAGES = ['invenio_accounts', 'invenio_groups',
                'invenio_records', 'invenio_tags', 'invenio_base']

    if not has_app_context():
        app = create_app(PACKAGES=PACKAGES)
        ctx = app.test_request_context('/')
        ctx.push()
Exemple #8
0
    def _init_flask(self):
        """
        Initialize Flask application.

        The Flask application should only be created in the workers, thus
        this method should not be called from the __init__ method.
        """
        if not self.flask_app:
            from flask import current_app
            if current_app:
                self.flask_app = current_app
            else:
                from invenio_base.factory import create_app
                self.flask_app = create_app(CELERY_CONTEXT=True)
                from invenio_ext.sqlalchemy import db
                self.db = db
Exemple #9
0
 def create_app(self):
     """Create the Flask application for testing."""
     app = create_app(**self.config)
     app.testing = True
     return app
def main():
    """Execute script."""
    from invenio_base.factory import create_app
    app = create_app()
    manager.app = app
    manager.run()
Exemple #11
0
def main():
    """Execute script."""
    from invenio_base.factory import create_app
    app = create_app()
    manager.app = app
    manager.run()
def main():
    """Run manager."""
    from invenio_base.factory import create_app
    app = create_app()
    manager.app = app
    manager.run()
Exemple #13
0
 def create_app(self):
     """Create the Flask application for testing."""
     app = create_app(**self.config)
     app.testing = True
     return app
 def create_app(self):
     """Create the Flask application for testing."""
     from invenio_base.factory import create_app
     app = create_app(**self.config)
     app.testing = True
     return app