def test_check_unused(self): config = ConfigStore() d = { 'server': { 'name': 'wat', 'unreg1': 'nothing', }, 'unreg2': { 'unreg3': 'should not be warned about' } } config.load_from_dict(d) server_config = config.section('server') name = server_config.option('name') one = config.check_unused() two = { 'server': { 'unreg1': 'nothing', }, 'unreg2': { 'unreg3': 'should not be warned about' } } self.assertEqual(one, two)
def test_reload(self): config = ConfigStore() f = StringIO(SIMPLE_TOML_CONFIG) config.load_from_file(f) server_config = config.section('server') port = server_config.option('port', default=32887) self.assertEqual(port.get(), 4567) config.load_from_dict({}) self.assertEqual(port.get(), 32887) port.set(456) self.assertEqual(port.get(), 456) config.load_from_dict({}) port.set(5555) self.assertEqual(port.get(), 5555)
def test_raw_loading(self): config = ConfigStore() config.load_from_dict({}) name = config.option('name') port = config.section('server').option('port') obj = {'server': {'port': 4567}, 'name': 'thing'} config.load_from_dict(obj) self.assertEqual(name.get(), 'thing') obj = {'server': {'port': 42}} config.update_from_dict(obj) self.assertEqual(port.get(), 42) self.assertEqual(name.get(), 'thing') obj = {'server': {'port': 4567}, 'name': 'thing'} config.load_from_dict(obj) self.assertEqual(port.get(), 4567) self.assertEqual(name.get(), 'thing')