def test_set_config_uppercase(self): self.write_good_file() self.config.set_config('NewKey', 'new_value') self.config.save() # re-read the config file self.config2 = Configuration(self.config_file_path) # Check value. self.assertEqual('new_value', self.config2.get_config('newkey'))
def set_encoding(self, name): """ Change the encoding of the repository. """ # Check if the given name if valid encoding. encoding = encodings.search_function(name.lower()) assert encoding is not None # Need to update the 'rdiffweb' file hint_file = os.path.join(self.data_path, b"rdiffweb") logger.debug("writing hints for [%r]", self.repo_root) config = Configuration(hint_file) config.set_config('encoding', name) config.save() # Also update current encoding. self.encoding = encoding
def _load_hints(self): """For different purpose, a repository may contains an "rdiffweb" file to provide hint to rdiffweb related to locale. At first, it's used to define an encoding.""" hint_file = os.path.join(self.data_path, b"rdiffweb") if not os.access(hint_file, os.F_OK) or os.path.isdir(hint_file): return # Read rdiffweb file asconfiguration file. config = Configuration(hint_file) name = config.get_config('encoding', default=FS_ENCODING) self.encoding = encodings.search_function(name.lower()) if not self.encoding: encodings.search_function(FS_ENCODING) assert self.encoding
def set_encoding(self, name): """ Change the encoding of the repository. """ # Check if the given name if valid encoding. encoding = encodings.search_function(name.lower()) assert encoding is not None # Get encoding name (as unicode) name = encoding.name if not isinstance(name, str): name = name.decode('ascii') # Need to update the 'rdiffweb' file logger.debug("writing hints for [%r]", self.full_path) config = Configuration(self._hint_file) config.set_config('encoding', name) config.save() # Also update current encoding. self._encoding = encoding
def test_get_plugin_infos_with_egg(self): """ Check plugin information. """ # Enable a single plugin. config = Configuration() config.set_config('SQLiteEnabled', 'true') plugins = PluginManager(config) infos = plugins.get_plugin_infos() # Check result. self.assertTrue(len(infos) > 0) plugin_info = next((i for i in infos if i.name == 'SQLite'), None) self.assertEqual('SQLite', plugin_info.name) # self.assertEqual('SQLite', plugin_info.version) self.assertEqual('Patrik Dufresne', plugin_info.author) self.assertEqual('http://www.patrikdufresne.com/en/rdiffweb/', infos[0].url) self.assertEqual(True, plugin_info.enabled) self.assertEqual('GPLv3', plugin_info.copyright)
def write_bad_file(self, bad_setting_num): self.write_good_file() f = open(self.config_file_path, "w") f.write(self.bad_config_texts[bad_setting_num]) f.close() self.config = Configuration(self.config_file_path)
def write_good_file(self): f = open(self.config_file_path, "w") f.write(self.good_config_text) f.close() self.config = Configuration(self.config_file_path)