def test_add_setting(self): '''settings - new setting can be added and removed''' self.assertRaises(KeyError, lambda: settings['new_property']) settings.add_setting('new_property', 255) self.assertEqual(settings['new_property'], 255) settings.del_setting('new_property') self.assertRaises(KeyError, lambda: settings['new_property'])
def test_settings(self): '''settings''' key = 'some_nonexisting_key' value = 'my value' from gap.conf import settings self.assertRaises(KeyError, lambda: settings[key]) settings.add_setting(key, value) self.assertEquals(settings[key], value)
def test_composed_setting(self): '''settings - structured value save settings when changed''' settings.add_setting('test', {'a': 1}) self.assertEqual(settings['test'].a, 1) settings['test'].a = 2 self.assertEqual(settings['test'].a, 2) settings.reload() self.assertEqual(settings['test'].a, 2)