def del_global_setting(key): if settings.BACKEND == BACKEND_DJANGO: from aiida.backends.djsite.globalsettings import del_global_setting elif settings.BACKEND == BACKEND_SQLA: from aiida.backends.sqlalchemy.globalsettings import del_global_setting else: raise Exception("unknown backend {}".format(settings.BACKEND)) del_global_setting(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')