Esempio n. 1
0
 def test_adds_existing_user_to_admin_group(self):
     with session.begin():
         existing_user = data_setup.create_user()
         self.assertEquals(existing_user.groups, [])
     populate_db(user_name=existing_user.user_name)
     with session.begin():
         existing_user = User.query.get(existing_user.user_id)
         admin_group = Group.by_name(u'admin')
         self.assertEquals(existing_user.groups, [admin_group])
     # run the same thing again, should have no effect but should not break
     populate_db(user_name=existing_user.user_name)
Esempio n. 2
0
def setup_model(override=True):
    from bkr.server.tools.init import init_db, populate_db
    engine = turbogears.database.get_engine()
    db_name = engine.url.database
    connection = engine.connect()
    if override:
        log.info('Dropping database %s', db_name)
        connection.execute('DROP DATABASE IF EXISTS %s' % db_name)
    log.info('Creating database %s', db_name)
    connection.execute('CREATE DATABASE %s' % db_name)
    connection.invalidate() # can't reuse this one
    del connection
    log.info('Initialising model')
    init_db(metadata)
    populate_db(user_name=ADMIN_USER, password=ADMIN_PASSWORD,
            user_email_address=ADMIN_EMAIL_ADDRESS)
Esempio n. 3
0
def setup_model(override=True):
    from bkr.server.tools.init import init_db, populate_db
    engine = turbogears.database.get_engine()
    db_name = engine.url.database
    connection = engine.connect()
    if override:
        log.info('Dropping database %s', db_name)
        connection.execute('DROP DATABASE IF EXISTS %s' % db_name)
    log.info('Creating database %s', db_name)
    connection.execute('CREATE DATABASE %s' % db_name)
    connection.invalidate() # can't reuse this one
    del connection
    log.info('Initialising model')
    init_db(metadata)
    populate_db(user_name=ADMIN_USER, password=ADMIN_PASSWORD,
            user_email_address=ADMIN_EMAIL_ADDRESS)