def test_connection(self):
     config = Config(config_file_path)
     config.reload(config_file_path)
     config.set('General', 'debug', 'yes')
     rta_evt3_db_mysql = RTA_EVT3_DB('mysql', config_file_path)
     rta_evt3_db_redis = RTA_EVT3_DB('redis-basic', config_file_path)
     self.assertEqual(True, rta_evt3_db_mysql.dbConnector.testConnection())
     self.assertEqual(True, rta_evt3_db_redis.dbConnector.testConnection())
示例#2
0
 def test_singleton(self):
     config = Config(config_file_path)
     config.set('General', 'batchsize', 666)
     config = Config(config_file_path)
     self.assertEqual(666, config.get('General', 'batchsize'))
     config.reload(config_file_path)
示例#3
0
 def test_bool_false_cast(self):
     config = Config(config_file_path)
     config.set('General', 'debug', 'alksjdlkasjd')
     self.assertEqual(
         True, isinstance(config.get('General', 'debug', 'bool'), bool))
     self.assertEqual(False, config.get('General', 'debug', 'bool'))
示例#4
0
 def test_bool_true_cast(self):
     config = Config(config_file_path)
     config.set('General', 'debug', 'yes')
     self.assertEqual(
         True, isinstance(config.get('General', 'debug', 'bool'), bool))
     self.assertEqual(True, config.get('General', 'debug', 'bool'))
示例#5
0
 def test_float_cast(self):
     config = Config(config_file_path)
     config.set('General', 'mjdref', 666.666)
     self.assertEqual(
         True, isinstance(config.get('General', 'mjdref', 'float'), float))
     self.assertEqual(666.666, config.get('General', 'mjdref', 'float'))
示例#6
0
 def test_set_and_get_value(self):
     config = Config(config_file_path)
     config.set('General', 'batchsize', 666)
     self.assertEqual(666, config.get('General', 'batchsize'))
示例#7
0
def getConfig(config_file_path, debug, reload=False):
    config = Config(config_file_path)
    if reload:
        config.reload(config_file_path)
    config.set('General', 'debug', debug)
    return config