def testSearch(self):

        client=LDAPClientTestDriver([
            pureldap.LDAPSearchResultEntry(
            objectName='cn=foo,dc=example,dc=com',
            attributes=(('foo', ['a']),
                        ('bar', ['b', 'c']),
                        ),
            ),
            pureldap.LDAPSearchResultEntry(
            objectName='cn=bar,dc=example,dc=com',
            attributes=(('foo', ['a']),
                        ('bar', ['d', 'e']),
                        ),
            ),
            pureldap.LDAPSearchResultDone(
            resultCode=0,
            matchedDN='',
            errorMessage='')
            ])

        o=ldapsyntax.LDAPEntry(client=client,
                               dn='dc=example,dc=com',
                               attributes={
            'objectClass': ['organizationalUnit'],
            })

        d=o.search(filterText='(foo=a)',
                   attributes=['foo', 'bar'])
        def cb(val):
            client.assertSent(pureldap.LDAPSearchRequest(
                baseObject='dc=example,dc=com',
                scope=pureldap.LDAP_SCOPE_wholeSubtree,
                derefAliases=pureldap.LDAP_DEREF_neverDerefAliases,
                sizeLimit=0,
                timeLimit=0,
                typesOnly=0,
                filter=pureldap.LDAPFilter_equalityMatch(
                attributeDesc=pureldap.LDAPAttributeDescription(value='foo'),
                assertionValue=pureldap.LDAPAssertionValue(value='a')),
                attributes=['foo', 'bar']))
            self.failUnlessEqual(len(val), 2)

            self.failUnlessEqual(val[0],
                                 ldapsyntax.LDAPEntry(
                client=client,
                dn='cn=foo,dc=example,dc=com',
                attributes={
                'foo': ['a'],
                'bar': ['b', 'c'],
                }))

            self.failUnlessEqual(val[1],
                                 ldapsyntax.LDAPEntry(
                client=client,
                dn='cn=bar,dc=example,dc=com',
                attributes={
                'foo': ['a'],
                'bar': ['d', 'e'],
                }))
        d.addCallback(cb)
        return d
Test searches.
dataset/ETHPy150Open twisted/ldaptor/ldaptor/test/test_ldapsyntax.py/LDAPSyntaxSearch.testSearch