Exemplo n.º 1
0
def main():
    database_config = read_config(database_config_template(),
                                  filter_section='sqlalchemy')
    setup_db(database_config)

    render_er(
        "{}://{}:{}@{}:{}/{}".format(database_config['drivername'],
                                     database_config['username'],
                                     database_config['password'],
                                     database_config['host'],
                                     database_config['port'],
                                     database_config['database']),
        os.path.join('..', '_static', 'img', 'schema_db.png'))
Exemplo n.º 2
0
def teardown_function(function):
    database_config = read_config(database_config_template())
    # FIXME: we are recreating the deployment directory but it should be
    # replaced by an temporary creation of folder.
    shutil.rmtree(function.deployment_dir, ignore_errors=True)
    db, _ = setup_db(database_config['sqlalchemy'])
    Model.metadata.drop_all(db)
Exemplo n.º 3
0
def test_setup_db(database):
    database_config = read_config(database_config_template(),
                                  filter_section='sqlalchemy')
    db, Session = setup_db(database_config)
    with db.connect() as conn:
        session = Session(bind=conn)
        file_type = session.query(SubmissionFileType).all()
        assert len(file_type) > 0
Exemplo n.º 4
0
def session_scope_function(database_config, ramp_config, database_connection):
    try:
        deployment_dir = create_test_db(database_config, ramp_config)
        with session_scope(database_config['sqlalchemy']) as session:
            yield session
    finally:
        shutil.rmtree(deployment_dir, ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 5
0
def make_toy_db(database_connection):
    database_config = read_config(database_config_template())
    ramp_config = ramp_config_template()
    try:
        deployment_dir = create_toy_db(database_config, ramp_config)
        yield
    finally:
        shutil.rmtree(deployment_dir, ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 6
0
def session_scope_function():
    database_config = read_config(database_config_template())
    ramp_config = read_config(ramp_config_template())
    try:
        yield
    finally:
        shutil.rmtree(ramp_config['ramp']['deployment_dir'],
                      ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 7
0
def session_scope_module():
    database_config = read_config(database_config_template())
    ramp_config = ramp_config_template()
    try:
        deployment_dir = create_toy_db(database_config, ramp_config)
        with session_scope(database_config['sqlalchemy']) as session:
            yield session
    finally:
        shutil.rmtree(deployment_dir, ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 8
0
def base_db():
    database_config = read_config(database_config_template())
    ramp_config = read_config(ramp_config_template())
    try:
        create_test_db(database_config, ramp_config)
        with session_scope(database_config['sqlalchemy']) as session:
            yield session
    finally:
        shutil.rmtree(ramp_config['ramp']['deployment_dir'],
                      ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 9
0
def session_scope_function(database_connection):
    database_config = read_config(database_config_template())
    ramp_config = read_config(ramp_config_template())
    try:
        yield
    finally:
        # FIXME: we are recreating the deployment directory but it should be
        # replaced by an temporary creation of folder.
        deployment_dir = os.path.commonpath(
            [ramp_config['ramp']['kit_dir'], ramp_config['ramp']['data_dir']])
        shutil.rmtree(deployment_dir, ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 10
0
def session_scope_function():
    database_config = read_config(database_config_template())
    ramp_config = ramp_config_template()
    try:
        deployment_dir = create_test_db(database_config, ramp_config)
        with session_scope(database_config['sqlalchemy']) as session:
            add_users(session)
            add_problems(session)
            add_events(session)
            yield session
    finally:
        shutil.rmtree(deployment_dir, ignore_errors=True)
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 11
0
def client():
    database_config = read_config(database_config_template())
    ramp_config = ramp_config_template()
    try:
        deployment_dir = create_toy_db(database_config, ramp_config)
        flask_config = generate_flask_config(database_config)
        app = create_app(flask_config)
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        yield app.test_client()
    finally:
        shutil.rmtree(deployment_dir, ignore_errors=True)
        try:
            # In case of failure we should close the global flask engine
            from ramp_frontend import db as db_flask
            db_flask.session.close()
        except RuntimeError:
            pass
        db, _ = setup_db(database_config['sqlalchemy'])
        Model.metadata.drop_all(db)
Exemplo n.º 12
0
def teardown_module(module):
    database_config = read_config(database_config_template())
    ramp_config = read_config(ramp_config_template())
    shutil.rmtree(ramp_config['ramp']['deployment_dir'], ignore_errors=True)
    db, _ = setup_db(database_config['sqlalchemy'])
    Model.metadata.drop_all(db)