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())
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)
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'))
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'))
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'))
def test_set_and_get_value(self): config = Config(config_file_path) config.set('General', 'batchsize', 666) self.assertEqual(666, config.get('General', 'batchsize'))
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