def test_dev_config(self):
        app = create_app("appname.settings.DevConfig", "dev")

        assert app.config["DEBUG"] == True
        assert app.config["SQLALCHEMY_DATABASE_URI"] == "sqlite://example.db"
        assert app.config["SQLALCHEMY_ECHO"] == True
        assert app.config["CACHE_TYPE"] == "null"
Beispiel #2
0
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

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

        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
def test_dev_config():
    app = create_app('appname.settings.DevConfig', 'dev')

    assert app.config['DEBUG'] == True
    assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite://example.db'
    assert app.config['SQLALCHEMY_ECHO'] == True
    assert app.config['CACHE_TYPE'] == 'null'
Beispiel #4
0
    def test_test_config(self):
        """ Tests if the test config loads correctly """

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

        assert app.config['DEBUG'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Beispiel #5
0
    def test_dev_config(self):
        app = create_app('appname.settings.DevConfig', env='dev')

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Beispiel #6
0
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

        app = create_app('appname.settings.ProdConfig')
        assert app.config['DEBUG'] is False

        assert app.config['CACHE_TYPE'] == 'redis'
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

        app = create_app('appname.settings.ProdConfig', env='prod')

        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #8
0
    def test_dev_config(self):
        app = create_app('appname.settings.DevConfig', env='dev')

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

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

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_ECHO'] is True
        assert app.config['CACHE_TYPE'] == 'null'
Beispiel #10
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

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

        assert app.config['DEBUG'] is True
        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'null'
Beispiel #11
0
    def test_prod_config(self):
        """ Tests if the production config loads correctly """

        app = create_app('appname.settings.ProdConfig', env='prod')

        assert app.config['SQLALCHEMY_DATABASE_URI'] == \
            'sqlite:///' + os.path.join(basedir, 'database.db')
        assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #12
0
 def setup(self):
     app = create_app('appname.settings.DevConfig', env='dev')
     self.app = app.test_client()
     db.app = app
     db.create_all()
     admin = User('admin', 'supersafepassword')
     db.session.add(admin)
     db.session.commit()
Beispiel #13
0
 def setup(self):
     app = create_app('appname.settings.DevConfig', env='dev')
     self.app = app.test_client()
     db.app = app
     db.create_all()
     admin = User('admin', 'supersafepassword')
     db.session.add(admin)
     db.session.commit()
 def setUp(self):
     app = create_app(TESTING=True)
     self.app = app.test_client()
     self.ctx = app.test_request_context()
     self.ctx.push()
     db.app = app
     db.create_all()
     self.cwd = os.path.dirname(os.path.realpath(__file__))
     self.create_fixtures()
Beispiel #15
0
    def test_dev_config(self):
        """ Tests if the development config loads correctly """

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

        assert app.config['DEBUG'] is True
        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #16
0
def testapp(request):
    app = create_app('appname.settings.Config')
    app.test_client_class = TestClient
    app.response_class = JSONResponse
    # client = app.test_client()

    db.app = app
    setup_db(app, db)
    db.create_all()
    update_perms(db)

    def teardown():
        with app.app_context():
            db.session.remove()
            db.drop_all()

    request.addfinalizer(teardown)

    return app
Beispiel #17
0
def testapp(request):
    app = create_app('appname.settings.TestConfig', env='dev')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        admin = User('admin', 'supersafepassword')
        db.session.add(admin)
        db.session.commit()

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

    request.addfinalizer(teardown)

    return client
Beispiel #18
0
def testapp(request):
    app = create_app('appname.settings.TestConfig')
    client = app.test_client()

    db.app = app
    db.create_all()

    if getattr(request.module, "create_user", True):
        admin = User('*****@*****.**', 'supersafepassword', admin=True)
        user = User('*****@*****.**', 'safepassword')
        db.session.add_all([admin, user])
        db.session.commit()

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

    request.addfinalizer(teardown)

    return client
Beispiel #19
0
#!/usr/bin/env python

import os

from datetime import datetime
from flask.ext.script import Manager, Server
from flask.ext.script.commands import ShowUrls, Clean
from appname import create_app
from appname.database import db
from appname.main.models import User, Role

# default to dev config because no one should use this in
# production anyway
env = os.environ.get('APPNAME_ENV', 'dev')
app = create_app('appname.settings.{}Config'.format(env.capitalize()))

manager = Manager(app)
manager.add_command("server", Server())
manager.add_command("show-urls", ShowUrls())
manager.add_command("clean", Clean())


@manager.shell
def make_shell_context():
    """ Creates a python REPL with several default imports
        in the context of the app
    """

    return dict(app=app, db=db, User=User)

Beispiel #20
0
#!/usr/bin/env python
import os

from flask.ext.script import Manager, Server
from flask.ext.script.commands import ShowUrls, Clean
from appname import create_app
from appname.models import db, User

# default to dev config because no one should use this in
# production anyway
env = os.environ.get('APPNAME_ENV', 'dev')
application = create_app('appname.settings.%sConfig' % env.capitalize(),
                         env=env)

manager = Manager(application)
manager.add_command("server", Server())
manager.add_command("show-urls", ShowUrls())
manager.add_command("clean", Clean())


@manager.shell
def make_shell_context():
    """ Creates a python REPL with several default imports
        in the context of the app
    """

    return dict(app=app, db=db, User=User)


@manager.command
def createdb():
Beispiel #21
0
    def test_prod_config(self):
        app = create_app('appname.settings.ProdConfig', env='prod')

        assert app.config['SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #22
0
import os

from appname import create_app

# Defaults to development environment
env = os.environ.get('APPNAME_ENV', 'development')
app = create_app('appname.config.%sConfig' % env.capitalize(), env=env)

app.run(debug=True)
Beispiel #23
0
def test_client(request):
    app = create_app('appname.config.TestingConfig', env='testing')
    client = app.test_client()

    return client
Beispiel #24
0
#!/usr/bin/env python
import os

from flask.ext.script import Manager, Server
from flask.ext.script.commands import ShowUrls, Clean
from appname import create_app
from appname.models import db, User

# default to dev config because no one should use this in
# production anyway
env = os.environ.get('APPNAME_ENV', 'dev')
app = create_app('appname.settings.%sConfig' % env.capitalize(), env=env)

manager = Manager(app)
manager.add_command("server", Server())
manager.add_command("show-urls",ShowUrls())
manager.add_command("clean",Clean())


@manager.shell
def make_shell_context():
    """ Creates a python REPL with several default imports
        in the context of the app
    """

    return dict(app=app, db=db, User=User)


@manager.command
def createdb():
    """ Creates a database with all of the tables defined in
    def test_prod_config(self):
        app = create_app("appname.settings.ProdConfig", "prod")

        assert app.config["SQLALCHEMY_DATABASE_URI"] == "postgresql://localhost/example"
        assert app.config["CACHE_TYPE"] == "simple"
Beispiel #26
0
from pytz import timezone

from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.mongodb import MongoDBJobStore, MongoClient
from apscheduler.executors.pool import ThreadPoolExecutor

from appname import create_app

app = create_app('appname.config.BaseConfig')

jobstores = {
    'default':
    MongoDBJobStore(client=MongoClient(app.config.get('MONGO_URI'))),
}
executors = {'default': ThreadPoolExecutor(20)}
job_defaults = {'coalesce': False, 'max_instances': 5}
scheduler_tz = timezone(app.config["TIME_ZONE"])
scheduler = BackgroundScheduler(jobstores=jobstores,
                                executors=executors,
                                job_defaults=job_defaults,
                                timezone=scheduler_tz)
scheduler.start()

app.scheduler = scheduler
Beispiel #27
0
    def test_prod_config(self):
        app = create_app('appname.settings.ProdConfig', env='prod')

        assert app.config[
            'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database.db'
        assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #28
0
 def setup(self):
     app = create_app('appname.settings.DevConfig', env='dev')
     self.app = app.test_client()
     db.app = app
     db.create_all()
Beispiel #29
0
 def setup(self):
     app = create_app("appname.settings.DevConfig", env="dev")
     self.app = app.test_client()
     db.app = app
     db.create_all()
Beispiel #30
0
    def test_test_config(self):
        """Tests test config loads correctly."""
        app = create_app('appname.config.TestingConfig', env='testing')

        assert app.config['DEBUG'] is False
Beispiel #31
0
    def test_dev_config(self):
        """Tests development config loads correctly."""
        app = create_app('appname.config.DevelopmentConfig', env='development')

        assert app.config['DEBUG'] is True
Beispiel #32
0
 def test_prod_config(self):
     """Tests production config loads correctly."""
     app = create_app('appname.config.ProductionConfig', env='production')
#!/usr/bin/env python
from flask_migrate import MigrateCommand
from flask_script import Manager, Server

from appname import create_app
from appname.models import db, User

app = create_app()

manager = Manager(app)
manager.add_command("server", Server())
manager.add_command('db', MigrateCommand)


@manager.shell
def make_shell_context():
    """ Creates a python REPL with several default imports
        in the context of the app
    """
    return dict(app=app, db=db, User=User)


if __name__ == "__main__":
    manager.run()
Beispiel #34
0
#!/usr/bin/env python

import os

from flask_script import Manager, Server, prompt_choices
from flask_script.commands import ShowUrls, Clean
from flask_migrate import Migrate, MigrateCommand
from appname import create_app
from appname.warmup import setup_db, update_perms
from appname.models import db, User
# default to dev config because no one should use this in
# production anyway
app = create_app('appname.settings.Config')
manager = Manager(app)


@manager.shell
def make_shell_context():
    """ Creates a python REPL with several default imports
        in the context of the app
    """

    return dict(app=app, db=db, User=User)


@manager.command
def create_db():
    '''
        create database and tables
    '''
    setup_db(app, db)
def test_prod_config():
    app = create_app('appname.settings.ProdConfig', 'prod')

    assert app.config['SQLALCHEMY_DATABASE_URI'] == 'postgresql://localhost/example'
    assert app.config['CACHE_TYPE'] == 'simple'
Beispiel #36
0
#!/usr/bin/env python3
"""
For WSGI Server
To run:
$ gunicorn -b 0.0.0.0:5000 wsgi:app
OR
$ export FLASK_APP=wsgi
$ flask run
"""
import os
from appname import create_app

env = os.environ.get('APPNAME_ENV', 'dev')
app = create_app('appname.settings.%sConfig' % env.capitalize())
Beispiel #37
0
#coding:utf-8
import appname 

app = appname.create_app('appname.settings.DevConfig', env='dev')
#app.run(port=10000, debug=True)