def get_global_setting_description(key): if settings.BACKEND == BACKEND_DJANGO: from aiida.backends.djsite.globalsettings import get_global_setting_description elif settings.BACKEND == BACKEND_SQLA: from aiida.backends.sqlalchemy.globalsettings import get_global_setting_description else: raise Exception("unknown backend {}".format(settings.BACKEND)) return get_global_setting_description(key)
def test_settings_methods(self): from aiida.backends.djsite.globalsettings import ( get_global_setting_description, get_global_setting, set_global_setting, del_global_setting) set_global_setting(key="aaa", value={'b': 'c'}, description="pippo") self.assertEqual(get_global_setting('aaa'), {'b': 'c'}) self.assertEqual(get_global_setting_description('aaa'), "pippo") self.assertEqual(get_global_setting('aaa.b'), 'c') self.assertEqual(get_global_setting_description('aaa.b'), "") del_global_setting('aaa') with self.assertRaises(KeyError): get_global_setting('aaa.b') with self.assertRaises(KeyError): get_global_setting('aaa')