Example #1
0
def drop_database():
    _app = create_app(env_name='TEST')
    ctx = _app.app_context()
    ctx.push()

    from middleman import db

    db.drop_all()
Example #2
0
def app(drop_database, request):
    _app = create_app(env_name='TEST')

    ctx = _app.app_context()
    ctx.push()

    from middleman import db

    db.drop_all()
    db.create_all()

    request.addfinalizer(lambda: ctx.pop())

    return _app
Example #3
0
    try:
        __import__(PROJECT_MODULE_NAME)
    except ImportError:
        sys.stderr.write("Error: Can't import the \"%s\" project module.\n" %
                         PROJECT_MODULE_NAME)
        sys.exit(1)

from flask.ext.script import Manager, Server, prompt_bool
from flask import current_app

from middleman import create_app
from middleman.database import db

from middleman.controllers import user_controller

manager = Manager(create_app())
manager.add_option('-e', '--env', dest='env_name', required=False, default='DEVELOPMENT')
manager.add_command('runserver', Server(host='0.0.0.0', port=5000))


class ServerTest(Server):
    """Run server in testing env
    """

    def handle(self, app, host, port, use_debugger, use_reloader,
               threaded, processes, passthrough_errors):
        with app.test_request_context():
            dropdb(confirm=False)
            syncdb(default_data=True, sample_data=True)
            super(ServerTest, self).handle(app, host, port, use_debugger,
                                           use_reloader, threaded, processes, passthrough_errors)