def test_load_branch_configuration(self): """Check that the configuration from the branch is loaded.""" config_files = [os.path.normpath(p) for p in config.get_config_files()] rootdir = os.environ['ROOTDIR'] branch_config = os.path.join(rootdir, "data", config.CONFIG_FILE) branch_logging_config = os.path.join( rootdir, "data", config.CONFIG_LOGS) self.assertIn(branch_config, config_files) self.assertIn(branch_logging_config, config_files)
def test_get_config_files_path_encoding(self): """Check that get_config_files uses paths in the right encoding.""" temp = self.mktemp() fake_path = os.path.join(temp, u"Ñandú") os.makedirs(fake_path) with open(os.path.join(fake_path, config.CONFIG_FILE), "w") as f: f.write("this is a fake config file") self.patch( config, "load_config_paths", lambda _: [fake_path.encode("utf8")]) config_files = config.get_config_files() branch_config = os.path.join(fake_path, config.CONFIG_FILE) self.assertIn(branch_config, config_files)
def test_old_default_config(self): """Test log_level upgrade hook with an old default config.""" self.cp.read(config.get_config_files()[0]) # fake an old config value = self.cp.get('logging', 'level.default') help = self.cp.get('logging', 'level.help') parser = self.cp.get('logging', 'level.parser') self.cp.set('__main__', 'log_level.default', value) self.cp.set('__main__', 'log_level.help', help) self.cp.set('__main__', 'log_level.parser', parser) self.cp.remove_option('logging', 'level.default') self.cp.remove_option('logging', 'level.help') self.cp.remove_option('logging', 'level.parser') # parse it self.cp.parse_all() new_value = self.cp.get('logging', 'level') self.assertEqual(new_value.value, new_value.parser(value))