def test_get_properties(self): config_file = os.path.join(DIR, 'resources', 'valid.properties') conf = config.get_conf_from_properties_file(config_file) self.assertEqual( conf, { 'a': '1', 'b': '2', 'c': '3', 'd\\=': '4', 'e\\:': '5', 'f': '==6', 'g': '= 7', 'h': ':8', 'i': '9', 'j': '${ENVIRONMENT_VARIABLE}' })
def get_presto_conf(conf_dir): if os.path.isdir(conf_dir): file_list = [name for name in os.listdir(conf_dir) if name in PRESTO_FILES] else: _LOGGER.debug("No directory " + conf_dir) file_list = [] conf = {} for filename in file_list: ext = os.path.splitext(filename)[1] file_path = os.path.join(conf_dir, filename) if ext == ".properties": conf[filename] = get_conf_from_properties_file(file_path) elif ext == ".config": conf[filename] = get_conf_from_config_file(file_path) return conf
def get_presto_conf(conf_dir): if os.path.isdir(conf_dir): file_list = [ name for name in os.listdir(conf_dir) if name in PRESTO_FILES ] else: _LOGGER.debug("No directory " + conf_dir) file_list = [] conf = {} for filename in file_list: ext = os.path.splitext(filename)[1] file_path = os.path.join(conf_dir, filename) if ext == ".properties": conf[filename] = get_conf_from_properties_file(file_path) elif ext == ".config": conf[filename] = get_conf_from_config_file(file_path) return conf
def test_get_properties_ignores_whitespace(self, open_mock): file_manager = open_mock.return_value.__enter__.return_value file_manager.read.return_value = ' key1 =value1 \n \n key2= value2' conf = config.get_conf_from_properties_file('/dummy/path') self.assertEqual(conf, {'key1': 'value1', 'key2': 'value2'})
def test_expending_environment_variable(self, environment_variables): config_file = os.path.join(DIR, 'resources', 'environment_variable.properties') conf = config.get_conf_from_properties_file(config_file) self.assertTrue(environment_variables.called) self.assertEqual({'a': 'environment_variable_value'}, conf)
def test_file_is_empty_properties(self): emptyconf = {} conf = config.get_conf_from_properties_file(DIR + '/resources/empty.txt') self.assertEqual(conf, emptyconf)
def test_get_properties(self): config_file = os.path.join(DIR, 'files', 'valid.properties') conf = config.get_conf_from_properties_file(config_file) self.assertEqual(conf, {'a': '1', 'b': '2', 'c': '3', 'd\\=': '4', 'e\\:': '5', 'f': '==6', 'g': '= 7', 'h': ':8', 'i': '9'})
def test_file_is_empty_properties(self): emptyconf = {} conf = config.get_conf_from_properties_file(DIR + '/files/empty.txt') self.assertEqual(conf, emptyconf)