Esempio n. 1
0
def init_database():
    # Create the database and the database table(s)
    database.create_all()

    yield database  # this is where the testing happens!

    database.drop_all()
def test_client():
    flask_app = create_app()
    flask_app.config.from_object('config.TestingConfig')

    # Create a test client using the Flask appl config made for testing
    with flask_app.test_client() as testing_client:
        # Establish an application context before accessing the logger and database
        with flask_app.app_context():
            flask_app.logger.info(
                'Creating database tables in test_client fixture...')

            # Create the database and the database table(s)
            database.create_all()

        yield testing_client  # this is where the testing happens!

        with flask_app.app_context():
            database.drop_all()
def test_client():
    flask_app = create_app()
    flask_app.config.from_object('config.TestingConfig')
    flask_app.extensions['mail'].suppress = True

    # Create a test client using the Flask application configured for testing
    with flask_app.test_client() as testing_client:
        # Establish an application context before accessing the logger
        with flask_app.app_context():
            current_app.logger.info('In the test_client() fixture...')

            # Create the database and the database tables
            database.create_all()

        yield testing_client

        with flask_app.app_context():
            database.drop_all()
Esempio n. 4
0
def create_db():
    database.create_all()
    database.session.commit()
Esempio n. 5
0
def recreate_db():
    database.drop_all()
    database.create_all()
    database.session.commit()