當前位置: 首頁>>代碼示例>>Python>>正文


Python LDAPClient.get_group_members方法代碼示例

本文整理匯總了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)
開發者ID:generica,項目名稱:karaage,代碼行數:9,代碼來源:ldap_datastore.py

示例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]')
開發者ID:levlafayette,項目名稱:karaage,代碼行數:86,代碼來源:tests.py


注:本文中的placard.client.LDAPClient.get_group_members方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。