예제 #1
0
def db_create_tables():
    app = create_app()
    with app.app_context():
        db.drop_all()
        db.create_all()
    yield
    with app.app_context():
        db.drop_all()
예제 #2
0
def initdb():
    "Clear the existing database and create a fresh one (drop_all && create_all)"

    if prompt_bool("Are you sure you want to lose all your data"):
        db.drop_all()
        db.create_all()

    load_all_fixtures(db, app)
    db.session.commit()
예제 #3
0
def app(monkey_session) -> Flask:
    """A testing instance of the Flask application."""

    monkey_session.setenv('APP_ENV', 'testing')
    app = create_app()

    # Creates in memory tables..
    with app.app_context():
        db.create_all()

    yield app

    # Drops from memory tables.
    with app.app_context():
        db.drop_all()
예제 #4
0
def base_setup():
    """
    This function prepares and destruct the flask application and the database
    before and after each test.
    All lines before the yield statement will be executed before the tests
    and each line after the yield statement will be called at the end of the tests
    """
    app, _ = create_app(config_file="config_test.ini", test=True)
    app_context = app.app_context()
    app_context.push()
    create_testEnv(app, db)
    client = app.test_client()

    yield app, app_context, db, client

    db.session.remove()
    db.drop_all()
    app_context.pop()
예제 #5
0
파일: dev.py 프로젝트: sharebears/pulsar
def insertdata():
    """Recreate and repopulate an existing testing database."""
    with app.test_request_context():
        flask.g.cache_keys = defaultdict(set)

        try:
            user = User.from_pk(1)
        except sqlalchemy.exc.ProgrammingError as e:
            click.secho(
                'Please manually create the database before running the createdata command.',
                fg='red',
                bold=True,
            )
            raise click.Abort

        if user and user.username != 'user_one':
            click.secho(
                'The username of the first user is not user_one. Are you sure this '
                'is a testing database? Please clear it yourself and re-try.',
                fg='red',
                bold=True,
            )
            raise click.Abort

        cache.clear()
        db.session.commit()

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

    with app.test_request_context():
        for p in POPULATORS:
            p.populate()
        CorePopulator.add_permissions(SitePermissions.GOD_MODE)
        cache.clear()

    click.echo(f'Updated and inserted development data into the database!')
예제 #6
0
def db_drop():
    db.drop_all()
    print('Database dropped!')
예제 #7
0
def drop_db():
    """Drops the db tables."""
    db.drop_all()
예제 #8
0
def dropdb():
    "Clear the existing database (drop_all)"

    if prompt_bool("Are you sure you want to lose all your data"):
        db.drop_all()
예제 #9
0
def drop_db():
    db.drop_all()
예제 #10
0
def testTearDown(self):
    db.session.remove()
    db.drop_all()
    os.remove(DATABASE_PATH)
예제 #11
0
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
    return 'Database Recreated'
예제 #12
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
예제 #13
0
def testTearDown(self):
    db.session.remove()
    db.drop_all()
    os.remove(DATABASE_PATH)
예제 #14
0
파일: tests.py 프로젝트: hirmeos/altmetrics
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
예제 #15
0
def drop_tables():
    """Drop my db tables."""
    db.drop_all()
    print('***** Datebase Tables Dropped ****')
예제 #16
0
from flask import Flask, render_template, request, jsonify
from core import db
from models.plant import Plant
from models.log import Log
import arrow

#Time & Date
utc = arrow.utcnow()
local = utc.to('US/Pacific')

application = Flask(__name__)
app = application

app.config.from_pyfile('config.py')
db.init_app(app)

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

#Blueprint imports
from controllers.page import index
app.register_blueprint(index)

from controllers.api import api
app.register_blueprint(api)

if __name__ == '__main__':
    app.run(host='0.0.0.0')
예제 #17
0
    def setUp(self):
        db.drop_all()
        with self.app.app_context():
            db.create_all()

        self.init_db()
예제 #18
0
 def tearDown(self):
     close_all_sessions()
     db.drop_all()
예제 #19
0
def main():
    app = create_app()
    with app.app_context():
        db.drop_all()
        db.create_all()
        db.session.commit()