Пример #1
0
def test_bad_app_with_failsafe():
    # creating the app should not raise an exception
    app = failsafe(create_bad_app)()

    # but fetching the page should
    with pytest.raises(MyException):
        app.test_client().get('/')
Пример #2
0
def create_app(store):
    from flask import Flask
    app = Flask(__name__)
    app.config.from_object('palisade.settings')

    # Setup session storage
    from flaskext.kvsession import KVSessionExtension
    KVSessionExtension(store, app)

    import rest
    app.register_blueprint(rest.blueprint, url_prefix='/api')
    return app

# use failsafe tool when using bare flask
from flask_failsafe import failsafe
create_app_flask_dbg = failsafe(create_app)

app = None
sys.path.append(os.getcwd()) # TODO: why do i need this?
if 'SERVER_SOFTWARE' in os.environ:
    if os.environ['SERVER_SOFTWARE'].startswith('Dev'):
        DEBUG_MODE = True
    from simplekv.gae import NdbStore
    from google.appengine.ext import ndb
    class Session(ndb.Expando):
        pass
    store = NdbStore(Session)
    app = create_app(store)
else:
    from simplekv.memory import DictStore
    store = DictStore()
Пример #3
0
def test_good_app():
    app = failsafe(create_good_app)()
    rv = app.test_client().get('/')
    assert b'Hello' in rv.data