Beispiel #1
0
def testapp(request):
    app = create_app('impression.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        admin = User(username="******", password="******")
        admin.insert()
        my_role = Role(name='admin')
        my_role.insert()
        admin.add_roles('admin')

        non_admin = User(username="******", password="******")
        non_admin.insert()

        safe_commit()

    def teardown():
        db.session.remove()
        db.drop_all()

    request.addfinalizer(teardown)

    return client
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

        app = create_app('impression.settings.DevConfig')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../impression/impression.db'
        assert app.config['CACHE_TYPE'] == 'null'
    def test_test_config(self):
        """ Tests if the test config loads correctly """

        app = create_app('impression.settings.TestConfig')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Beispiel #4
0
#!/usr/bin/env python
import os
from impression import create_app

# Get config and create app pattern.
env = os.environ.get('IMPRESSION_ENV', 'prod')
host = os.environ.get('IMPRESSION_HOST', '0.0.0.0')
app = create_app('impression.settings.{}Config'.format(env.capitalize()))

from impression.models import User, Setting, Role, Ability
from impression.mixin import db, safe_commit
# from flask import *

def main():
    """@todo: Docstring for main.
    :returns: @todo

    """
    with app.app_context():
        try:
            from IPython import embed
            embed()
        except ImportError:
            import os
            import readline
            from pprint import pprint
            os.environ['PYTHONINSPECT'] = 'True'

if __name__ == '__main__':
    main()
def main():
    # Get config and create app pattern.
    env = os.environ.get('IMPRESSION_ENV', 'prod')
    host = os.environ.get('IMPRESSION_HOST', '0.0.0.0')
    app = create_app('impression.settings.{}Config'.format(env.capitalize()))
    app.run(debug=app.config['DEBUG'], host=host)
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

        app = create_app('impression.settings.ProdConfig')

        assert app.config['CACHE_TYPE'] == 'simple'