def update_members(group_id, file_path, act_as=None): try: use_django_backend() except ImportError: settings = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings, 'GWS') members = [] with open(file_path, 'r') as f: for line in f: members.append( GroupEntity(name=line.strip(), type=GroupEntity.UWNETID_TYPE)) client = GWS(act_as=act_as, log_errors=True) errors = client.update_members(group_id, members) if len(errors): print(errors)
def guess_backend(): from django.conf import settings from commonconf.backends import use_django_backend use_django_backend()
def test_invalid(self): use_django_backend() with self.assertRaises(Exception): settings.MISSING_KEY_FOR_TESTING
def test_default_value(self): use_django_backend() value = getattr(settings, "MISSING_KEY_FOR_TESTING", "OK") self.assertEquals(value, "OK")
def test_valid(self): use_django_backend() value = settings.DEBUG