Ejemplo n.º 1
0
def app():
    # setup
    _app = create_app(TestConfig)

    # create test tables
    with _app.app_context():
        db.drop_all()
        db.create_all()

    yield _app

    # teardown
    with _app.app_context():
        db.drop_all()
Ejemplo n.º 2
0
def init_database():
    # Create the database and the database table
    db.create_all()

    # Insert user data
    user1 = UserModel('*****@*****.**', 'password1')
    user2 = UserModel('*****@*****.**', 'password2')
    user2 = UserModel('*****@*****.**', 'password')
    db.session.add(user1)
    db.session.add(user2)

    # Commit the changes for the users
    db.session.commit()

    yield db  # This is where the testing happens!

    db.drop_all()
Ejemplo n.º 3
0
def init_database():
    # Create the database and the database table
    db.create_all()

    # Insert user data
    user1 = User(email='*****@*****.**',
                 plaintext_password='******')
    user2 = User(email='*****@*****.**',
                 plaintext_password='******')
    db.session.add(user1)
    db.session.add(user2)

    # Commit the changes for the users
    db.session.commit()

    yield db  # this is where the testing happens!

    db.drop_all()
Ejemplo n.º 4
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 5
0
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
Ejemplo n.º 6
0
def reset_db():
    """Drop the database and recreate it."""
    db.drop_all()
    db.create_all()