Пример #1
0
def TestClient():
    test_app = create_app(config['testing'])
    test_client = test_app.test_client()
    ctx = test_app.app_context()
    ctx.push()
    yield test_client
    ctx.pop()
Пример #2
0
def test_client():
    flask_app = create_app('test')

    # Flask provides a way to test your application by exposing the Werkzeug test Client
    # and handling the context locals for you.
    testing_client = flask_app.test_client()

    # Establish an application context before running the tests.
    ctx = flask_app.app_context()
    ctx.push()

    yield testing_client  # this is where the testing happens!

    ctx.pop()
Пример #3
0
from flask_skeleton import create_app
from config import config
import os

if os.getenv('FLASK_ENV'):
    app_env = os.getenv('FLASK_ENV')
else:
    app_env = "default"

app = create_app(config[app_env])

if __name__ == "__main__":
    app.run()
Пример #4
0
import flask_skeleton
from flask_skeleton.models import db, User

# pylint: disable=invalid-name
app = flask_skeleton.create_app({
    'SECRET_KEY': 'completely_unsafe_dev_key',
    'DEBUG': True,
    'TESTING': True
})


def run():
    app.run(host='0.0.0.0', port=5000)


def reset_db():
    with app.app_context():
        db.drop_all()
        db.create_all()
        if app.debug:
            user = User(email='*****@*****.**', password='******')
            db.session.add(user)
            db.session.commit()

    print('Database', app.config['SQLALCHEMY_DATABASE_URI'], 'created')
Пример #5
0
import flask_skeleton
from flask_skeleton.models import db, User


# pylint: disable=invalid-name
app = flask_skeleton.create_app({
    'SECRET_KEY': 'completely_unsafe_dev_key',
    'DEBUG': True,
    'TESTING': True
})


def run():
    app.run(host='0.0.0.0', port=5000)


def reset_db():
    with app.app_context():
        db.drop_all()
        db.create_all()
        if app.debug:
            user = User(email='*****@*****.**', password='******')
            db.session.add(user)
            db.session.commit()

    print('Database', app.config['SQLALCHEMY_DATABASE_URI'], 'created')
Пример #6
0
from typing import Dict, Any

from flask_skeleton import create_app, db

app = create_app("dev")
app.app_context().push()


@app.shell_context_processor
def make_shell_context() -> Dict[str, Any]:
    """Make objects available during shell"""

    return {
        "db": db,
    }


if __name__ == "__main__":
    app.run(port=5000)