コード例 #1
0
def database(app):

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

        yield db
コード例 #2
0
    def setup(self):
        app = create_test_app()
        self.app = app
        self.client = app.test_client()

        with app.app_context():
            db.drop_all()
            db.create_all()
コード例 #3
0
def drop_db():
    app = Flask(__name__)
    app.config.from_object(os.environ['APP_SETTINGS'])
    db.init_app(app)

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

    return None
コード例 #4
0
def init_empty_database(app):
    with app.app_context():
        # Create the database
        db.create_all()

        yield  # tests run here

        # Destroy the database
        db.drop_all()
コード例 #5
0
ファイル: suite.py プロジェクト: hustlzp/wochang
    def setup(self):
        os.environ['MODE'] = 'TESTING'

        app = create_app()
        self.app = app
        self.client = app.test_client()

        with app.app_context():
            db.drop_all()
            db.create_all()
コード例 #6
0
def create_db(app):
    """
    A test fixture for creating a database table, with the schema defined in model, 
    once per test class and deleted after exiting the scope of a test class.
    """
    db.app = app
    with app.app_context():
        db.create_all()
        yield db
        db.session.close()
        db.drop_all()
コード例 #7
0
def db(app):
    _db.app = app

    connection = _db.engine.connect()
    config = Config(os.path.abspath('alembic.ini'))
    config.attributes['connection'] = connection
    command.upgrade(config, 'head')

    yield _db

    connection.close()
    _db.drop_all()
コード例 #8
0
def app_old():
    """
    Fixture app returning an instance of Flask app
    with created models in the database
    """

    app = create_app("testing")
    with app.app_context():
        db.create_all()

        yield app
        db.drop_all()
コード例 #9
0
ファイル: conftest.py プロジェクト: tzengerink/groceries-api
def db(app):
    _db.app = app

    connection = _db.engine.connect()
    config = Config(os.path.abspath('alembic.ini'))
    config.attributes['connection'] = connection
    command.upgrade(config, 'head')

    yield _db

    connection.close()
    _db.drop_all()
コード例 #10
0
def init_database(app, colors_list):
    with app.app_context():
        # Create the database
        db.create_all()

        # Insert color data
        for color in colors_list:
            db.session.add(Color(color=color['color'], value=color['value']))

        # Commit the changes
        db.session.commit()

        yield  # tests run here

        # Destroy the database
        db.drop_all()
コード例 #11
0
def clear():
    """Clear DB"""

    db.drop_all()
    db.create_all()

    # add admin user
    admin_user = User(username='******',
                      email='*****@*****.**',
                      password='******',
                      admin=True)
    db.session.add(admin_user)
    db.session.commit()

    flash("Database refreshed")
    return redirect(url_for('main_bp.chat'))
コード例 #12
0
ファイル: users.py プロジェクト: austineinstein/NN
def run():
    with app.app_context():
        db.drop_all()
        db.create_all()

        # Administrator
        admin = User(email="*****@*****.**")
        db.session.add(admin)

        # First user
        user1 = User(email="*****@*****.**")
        db.session.add(user1)

        # Second user
        user2 = User(email="*****@*****.**")
        db.session.add(user2)

        db.session.commit()
コード例 #13
0
def run():
    with app.app_context():
        
        print(f"ran users script. DB: {db}")

        db.drop_all()
        db.create_all()

        # Admin user
        admin = User(email="*****@*****.**")
        db.session.add(admin)

        # First base user
        user1 = User(email="*****@*****.**")
        db.session.add(user1)

        # Second base user
        user2 = User(email="*****@*****.**")
        db.session.add(user2)

        print(f"user.first(): {User.query.first()}")

        db.session.commit()
コード例 #14
0
def db_rebuild():
    db.drop_all()
    db.create_all()
    return "Database rebuilt!"
コード例 #15
0
ファイル: suite.py プロジェクト: 0xsKu/Flask-Boost
 def teardown(self):
     with self.app.app_context():
         db.drop_all()
コード例 #16
0
def app():
    """Flask application fixture """
    _app = build_app(env='test')
    db.create_all()
    yield _app
    db.drop_all()
コード例 #17
0
 def teardown(self):
     with self.app.app_context():
         db.drop_all()
コード例 #18
0
from application.models import db, Alert

db.drop_all()
db.create_all()

print Alert.query.all()
コード例 #19
0
ファイル: create_db.py プロジェクト: rabc/promessometro
from application.models import db, UserAdmin
db.drop_all()
db.create_all()

# create admin first user
adm_user = UserAdmin(email='*****@*****.**', password='******')
db.session.add(adm_user)
db.session.commit()
コード例 #20
0
ファイル: app.py プロジェクト: jairojair/ezipcode
def resetdb():
    """drop database tables"""
    db.drop_all()