def test_nested_update(self): config = ConfigStore() f = StringIO(SIMPLE_TOML_CONFIG) config.load_from_file(f) updates = {'server': {'things': {'thing2': 'added'}}} config.update_from_dict(updates) raw = config.get_dict() self.assertEqual(raw['server']['things']['thing1'], 'something') self.assertEqual(raw['server']['things']['thing2'], 'added') self.assertEqual(raw['server']['name'], 'piqueserver instance')
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')