Пример #1
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False  # otherwise redirects aren't going to return right status
     app.config['SQLALCHEMY_DATABASE_URI'] = app.config['TEST_SQLALCHEMY_DATABASE_URI']
     db.init_db_engine(app.config['TEST_SQLALCHEMY_DATABASE_URI'])
     return app
Пример #2
0
 def create_app(self):
     app = create_app(config_path=os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         'test_config.py'
     ))
     db.init_db_engine(app.config['SQLALCHEMY_DATABASE_URI'])
     return app
Пример #3
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     app.config[
         'DEBUG_TB_INTERCEPT_REDIRECTS'] = False  # otherwise redirects aren't going to return right status
     app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
         'TEST_SQLALCHEMY_DATABASE_URI']
     return app
Пример #4
0
    def test_flask_debugtoolbar(self):
        """ Test if flask debugtoolbar is loaded correctly

        Creating an app with default config so that debug is True
        and SECRET_KEY is defined.
        """
        app = create_app(debug=True, config_path='test_config.py')
        client = app.test_client()
        resp = client.get('/about')
        self.assert200(resp)
        self.assertIn('flDebug', str(resp.data))
Пример #5
0
    def test_flask_debugtoolbar(self):
        """ Test if flask debugtoolbar is loaded correctly

        Creating an app with default config so that debug is True
        and SECRET_KEY is defined.
        """
        app = create_app(debug=True)
        client = app.test_client()
        resp = client.get('/about')
        self.assert200(resp)
        self.assertIn('flDebug', str(resp.data))
Пример #6
0
def test(init_db=True, coverage=True):
    """Run all tests.

    It will also initialize the test database and create code coverage report, unless
    specified otherwise. Database that will be used for tests can be specified in the
    application config file. See `TEST_SQLALCHEMY_DATABASE_URI` variable.

    Code coverage report will be located in cover/index.html file.
    """
    if init_db:
        # Creating database-related stuff
        init_postgres(create_app().config['TEST_SQLALCHEMY_DATABASE_URI'])

    if coverage:
        local(
            "nosetests --exe --with-coverage --cover-package=metabrainz --cover-erase --cover-html"
        )
        print(
            yellow("Coverage report can be found in cover/index.html file.",
                   bold=True))
    else:
        local("nosetests --exe")
Пример #7
0
def cleanup_logs():
    with create_app().app_context():
        AccessLog.remove_old_ip_addr_records()
Пример #8
0
from werkzeug.serving import run_simple
from metabrainz import db
from metabrainz import create_app
from metabrainz.model.access_log import AccessLog
import urllib.parse
import subprocess
import os
import click

ADMIN_SQL_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'admin', 'sql')

cli = click.Group()
application = create_app()


@cli.command()
@click.option("--host", "-h", default="0.0.0.0", show_default=True)
@click.option("--port", "-p", default=8080, show_default=True)
@click.option("--debug", "-d", is_flag=True,
              help="Turns debugging mode on or off. If specified, overrides "
                   "'DEBUG' value in the config file.")
def runserver(host, port, debug=False):
    run_simple(
        hostname=host,
        port=port,
        application=application,
        use_debugger=debug,
        use_reloader=debug,
    )

Пример #9
0
def runserver(host, port, debug):
    create_app().run(host=host, port=port, debug=debug)
Пример #10
0
def clear_memcached():
    with create_app().app_context():
        cache.flush_all()
    print(green("Flushed everything from memcached.", bold=True))
Пример #11
0
def runserver(host, port, debug):
    create_app().run(host=host, port=port, debug=debug)
Пример #12
0
 def create_app(self):
     app = create_app(config_path=os.path.join(
         os.path.dirname(os.path.realpath(__file__)), 'test_config.py'))
     db.init_db_engine(app.config['SQLALCHEMY_DATABASE_URI'])
     return app