本文整理汇总了Python中placard.client.LDAPClient.get_group_members方法的典型用法代码示例。如果您正苦于以下问题:Python LDAPClient.get_group_members方法的具体用法?Python LDAPClient.get_group_members怎么用?Python LDAPClient.get_group_members使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类placard.client.LDAPClient
的用法示例。
在下文中一共展示了LDAPClient.get_group_members方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_members
# 需要导入模块: from placard.client import LDAPClient [as 别名]
# 或者: from placard.client.LDAPClient import get_group_members [as 别名]
def get_members(self, software):
conn = LDAPClient()
try:
return conn.get_group_members('gidNumber=%s' % software.gid)
except:
return []
del(conn)
示例2: stest_register_project
# 需要导入模块: from placard.client import LDAPClient [as 别名]
# 或者: from placard.client.LDAPClient import get_group_members [as 别名]
def stest_register_project(self):
self.assertEquals(len(mail.outbox), 0)
response = self.client.get(reverse('project_registration'))
self.failUnlessEqual(response.status_code, 200)
hash_ = response.content[response.content.find('name="captcha_0" value="')+24:response.content.find('name="captcha_0" value="')+64]
try:
captcha_text = CaptchaStore.objects.get(hashkey=hash_).response
except:
self.fail()
form_data = {
'title' : 'Mr',
'first_name': 'Jim',
'last_name': 'Bob',
'position': 'Researcher',
'institute': 1,
'department': 'Maths',
'email': '[email protected]',
'country': 'AU',
'telephone': '4444444',
'username': 'jimbob',
'password1': 'Exaiquouxei0',
'password2': 'Exaiquouxei0',
'needs_account': True,
'project_name': 'Lasers',
'project_institute': 1,
'project_description': 'Lasers are cool',
'tos': True,
'captcha_0': hash_,
'captcha_1': captcha_text,
}
response = self.client.post(reverse('project_registration'), form_data, follow=True)
project_request = ProjectCreateRequest.objects.get(pk=1)
self.failUnlessEqual(response.redirect_chain[0][0], 'http://testserver' + reverse('project_created', args=[project_request.id]))
self.failUnlessEqual(response.status_code, 200)
self.assertEquals(len(mail.outbox), 1)
self.assertEquals(mail.outbox[0].subject, 'TestOrg new project request')
self.assertEquals(mail.outbox[0].from_email, settings.ACCOUNTS_EMAIL)
self.assertEquals(mail.outbox[0].to[0], '[email protected]')
person = Person.objects.get(user__username='jimbob')
self.failUnlessEqual(project_request.needs_account, True)
self.failUnlessEqual(person.is_active, False)
project = Project.objects.get(name='Lasers')
self.failUnlessEqual(project.is_active, False)
self.failUnlessEqual(project.pid, 'pExam0001')
self.failUnlessEqual(project.projectcreaterequest_set.all()[0], person.projectcreaterequest_set.all()[0])
lcon = LDAPClient()
lgroup = lcon.get_group('cn=%s' % project.pid)
self.failUnlessEqual(lgroup.cn, project.pid)
# Delegate logs in to approve
logged_in = self.client.login(username='kgtestuser1', password='aq12ws')
self.failUnlessEqual(logged_in, True)
response = self.client.get(reverse('user_project_request_detail', args=[project_request.id]))
self.failUnlessEqual(response.status_code, 200)
self.assertEquals(len(mail.outbox), 1)
response = self.client.post(reverse('user_approve_project', args=[project_request.id]))
self.failUnlessEqual(response.status_code, 302)
self.failUnlessRaises(ProjectCreateRequest.DoesNotExist, ProjectCreateRequest.objects.get, pk=project_request.id)
project = Project.objects.get(name='Lasers')
self.failUnlessEqual(project.is_active, True)
self.failUnlessEqual(project.users.all()[0], person)
lgroup = lcon.get_group('cn=%s' % project.pid)
lgroup_members = lcon.get_group_members('cn=%s' % project.pid)
self.failUnlessEqual(lgroup_members[0].uid, project.users.all()[0].username)
self.failUnlessEqual(lgroup.cn, project.pid)
person = Person.objects.get(user__username='jimbob')
self.failUnlessEqual(person.is_active, True)
self.assertEquals(len(mail.outbox), 2)
self.assertEquals(mail.outbox[1].subject, 'TestOrg Project has been approved')
self.assertEquals(mail.outbox[1].from_email, settings.ACCOUNTS_EMAIL)
self.assertEquals(mail.outbox[1].to[0], '[email protected]')