예제 #1
0
 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}'
         })
예제 #2
0
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
예제 #3
0
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
예제 #4
0
 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'})
예제 #5
0
 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)
예제 #6
0
 def test_file_is_empty_properties(self):
     emptyconf = {}
     conf = config.get_conf_from_properties_file(DIR +
                                                 '/resources/empty.txt')
     self.assertEqual(conf, emptyconf)
예제 #7
0
 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'})
예제 #8
0
 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'})
예제 #9
0
 def test_file_is_empty_properties(self):
     emptyconf = {}
     conf = config.get_conf_from_properties_file(DIR + '/files/empty.txt')
     self.assertEqual(conf, emptyconf)