#NEWLINE# def testSearch( self ) : #NEWLINE# #INDENT# 'Test searches.' #NEWLINE# 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 = '' ) ] ) #NEWLINE# o = ldapsyntax . LDAPEntry ( client = client , dn = 'dc=example,dc=com' , attributes = { #NEWLINE# #INDENT# 'objectClass' : [ 'organizationalUnit' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# d = o . search ( filterText = '(foo=a)' , attributes = [ 'foo' , 'bar' ] ) #NEWLINE# def cb( val ) : #NEWLINE# #INDENT# 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' ] ) ) #NEWLINE# self . failUnlessEqual ( len ( val ) , 2 ) #NEWLINE# self . failUnlessEqual ( val [ 0 ] , ldapsyntax . LDAPEntry ( client = client , dn = 'cn=foo,dc=example,dc=com' , attributes = { #NEWLINE# #INDENT# 'foo' : [ 'a' ] , #NEWLINE# 'bar' : [ 'b' , 'c' ] , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . failUnlessEqual ( val [ 1 ] , ldapsyntax . LDAPEntry ( client = client , dn = 'cn=bar,dc=example,dc=com' , attributes = { #NEWLINE# #INDENT# 'foo' : [ 'a' ] , #NEWLINE# 'bar' : [ 'd' , 'e' ] , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# d . addCallback ( cb ) #NEWLINE# return d