def test_postgres_DbInfo(self):
     db_config = {'DB_TYPE':'postgres','DB_USERNAME':'******','DB_PASSWORD':'******'}        
     new_db_info = DbInfo(db_config)
     self.assertEqual(new_db_info.is_sqlite(),False)
     self.assertEqual(new_db_info.is_postgres(),True)                 
     self.assertEqual(new_db_info.db_username,'user')                 
     self.assertEqual(new_db_info.db_password,'password')                 
 def test_invalid_DbInfo(self):
     with self.assertRaises(Exception):
         new_db_info = DbInfo({},{})            
     with self.assertRaises(Exception):
         public_config = {'DB_TYPE':'postgres'}            
         new_db_info = DbInfo(public_config,{})            
     with self.assertRaises(Exception):
         public_config = {'DB_TYPE':'postgres','DB_USERNAME':'******'}                        
         new_db_info = DbInfo(public_config)            
示例#3
0
 def tearDown(self):
     db_url = db_util.generate_db_url(
         self.poop_db_name,
         DbInfo({
             'DB_TYPE': 'postgres',
             'DB_USERNAME': '******',
             'DB_PASSWORD': '******'
         }))
     drop_database(db_url)
def route_meta_admin_create_db_and_tournaments(init_players):    
    dummy_app = Flask('dummy_app')    
    db_config = td_config.get_db_config()    
    db_info = DbInfo(db_config)            
    db_util.create_db_and_tables(dummy_app, 'test', db_info , drop_tables=True)    
    db_handle = dummy_app.tables.db_handle
    create_stanard_roles_and_users(dummy_app)
    db_util.load_machines_from_json(dummy_app)
    orm_creation.init_papa_tournaments_divisions(dummy_app)
    orm_creation.init_papa_tournaments_division_machines(dummy_app)        
    if init_players == 1:
        orm_creation.init_papa_players(dummy_app,short=True,number_of_a_players=200)
    
    db_handle.engine.dispose()
    del dummy_app
    return jsonify({'data':'test'})    
示例#5
0
def get_admin_app(name):
    #FIXME : this actually gets ALL config values, not just db values
    db_config = td_config.get_db_config()
    #secret_config,public_config = td_config.get_configs()
    db_info = DbInfo(db_config)
    db_url = db_util.generate_db_url(name, db_info)
    if not database_exists(db_url):
        return None
    app = get_generic_app(name)
    db_handle = db_util.create_db_handle(db_url, app)
    app.tables = ImportedTables(db_handle)
    app.register_blueprint(admin_login_blueprint)
    app.register_blueprint(admin_manage_blueprint)
    LoginManager().init_app(app)
    auth.generate_user_loader(app)
    auth.generate_identity_loaded(app)
    for code in default_exceptions.iterkeys():
        app.error_handler_spec[None][code] = make_json_error
    return app
示例#6
0
 def setUp(self):
     super(TdIntegrationDispatchTestBase, self).setUp()
     dummy_app = Flask('dummy_app')
     #db_util.create_db_and_tables(dummy_app,self.poop_db_name,DbInfo({'DB_TYPE':'sqlite'}),drop_tables=True)
     self.assertFalse((os.getenv('DB_USERNAME', None) is None
                       or os.getenv('DB_PASSWORD', None) is None),
                      "You forgot to set DB_USERNAME and DB_PASSWORD")
     if os.getenv('USE_REAL_TEST_DB', None):
         self.poop_db_name = 'test'
     db_util.create_db_and_tables(dummy_app,
                                  self.poop_db_name,
                                  DbInfo({
                                      'DB_TYPE':
                                      'postgres',
                                      'DB_USERNAME':
                                      os.getenv('DB_USERNAME'),
                                      'DB_PASSWORD':
                                      os.getenv('DB_PASSWORD')
                                  }),
                                  drop_tables=True)
     del dummy_app
     self.app = PathDispatcher(app_build.get_meta_admin_app,
                               app_build.get_admin_app)
def route_meta_admin_wipe_test_db():        
    db_config = td_config.get_db_config()    
    db_info = DbInfo(db_config)            
    db_util.drop_database('test',db_info)
    return jsonify({'data':'test'})    
 def test_sqlite_DbInfo(self):
     public_config = {'DB_TYPE':'sqlite'}
     new_db_info = DbInfo({'DB_TYPE':'sqlite'})
     self.assertEqual(new_db_info.is_sqlite(),True)
     self.assertEqual(new_db_info.is_postgres(),False)