Exemplo n.º 1
0
def app():
    db_fd, db_fname = tempfile.mkstemp()

    dbtest_config = {
        "SQLALCHEMY_DATABASE_URI": "sqlite:///" + db_fname,
        "TESTING": True
    }
    app = create_app(dbtest_config)

    with app.app_context():
        db.create_all()

    yield app

    #app.db.session.remove()
    os.close(db_fd)
    os.unlink(db_fname)
Exemplo n.º 2
0
def client():
    db_fd, db_fname = tempfile.mkstemp()
    resourcetest_config = {
        "SQLALCHEMY_DATABASE_URI": "sqlite:///" + db_fname,
        "TESTING": True
    }

    app = create_app(resourcetest_config)

    #i = 0
    with app.app_context():
        db.create_all()
        #print("Numero: ", i+1)
        _populate_database()

    yield app.test_client()

    os.close(db_fd)
Exemplo n.º 3
0
from hub import create_app, db
from hub.models import User, ImageAnnotation, ImageContent, PhotoAnnotation

from datetime import datetime
import glob
import base64
from io import BytesIO
import os
from PIL import Image, ExifTags

config = os.getenv('FLASK_ENV')
print("configuration: ", config)

# -------------------------------------------------------------------
# creates app with defined environment and configuration
app = create_app(os.getenv('FLASK_ENV') or 'default')
with app.app_context():
    db.create_all()

    # -------------------------------------------------------------------
    # Testing User -model population

    # Create new row for new user to database by using User -model
    user1 = User(user_name="Meria Developer", user_password="******")
    user2 = User(user_name="Juha Engineer", user_password="******")
    user3 = User(user_name="Matti Meikäläinen", user_password="******")
    user4 = User(user_name="Katti ole' Matikainen",
                 user_password="******")
    user5 = User(user_name="Hessu Hopo :-) ", user_password="******")
    user6 = User(user_name="Juha Engineer", user_password="******")
Exemplo n.º 4
0
# ---------------------------
# Parse command line options
# ---------------------------
parser = argparse.ArgumentParser(description='script to start hub')
parser.add_argument('-d',
                    '--debug',
                    help='Launch app in debug mode.',
                    action="store_true",
                    required=False)
parser.add_argument('-p',
                    '--port',
                    help='Port to use in debug mode.',
                    default=5000,
                    type=int,
                    required=False)
args = parser.parse_args()

# ---------------------
# Create app instance
# ---------------------
from hub import create_app

app = create_app(debug=args.debug)

if __name__ == "__main__":
    if args.debug:
        app.run(debug=args.debug, port=args.port)
    else:
        app.run()