<s> from twisted . trial import unittest <EOL> from twisted . internet import reactor , protocol , address <EOL> from ldaptor . protocols . ldap import ldapconnector , distinguishedname <EOL> class FakeProto ( protocol . Protocol ) : <EOL> pass <EOL> class TestCallableOverride ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def testSimple ( self ) : <EOL> dn = distinguishedname . DistinguishedName ( '<STR_LIT>' ) <EOL> c = ldapconnector . LDAPClientCreator ( reactor , FakeProto ) <EOL> def _doConnect ( factory ) : <EOL> factory . doStart ( ) <EOL> factory . startedConnecting ( c ) <EOL> factory . buildProtocol ( address . IPv4Address ( '<STR_LIT>' , '<STR_LIT:localhost>' , '<STR_LIT:1>' ) ) <EOL> d = c . connect ( dn , overrides = { dn : _doConnect , } ) <EOL> def cb ( r ) : <EOL> self . failUnless ( isinstance ( r , FakeProto ) ) <EOL> d . addCallback ( cb ) <EOL> return d <EOL> def testFindOverride_plainString ( self ) : <EOL> """<STR_LIT>""" <EOL> c = ldapconnector . LDAPConnector ( reactor = None , <EOL> dn = '<STR_LIT>' , <EOL> factory = None ) <EOL> o = c . _findOverRide ( dn = distinguishedname . DistinguishedName ( '<STR_LIT>' ) , <EOL> overrides = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> } ) <EOL> self . assertEquals ( o , ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> def testFindOverride_root ( self ) : <EOL> """<STR_LIT>""" <EOL> c = ldapconnector . LDAPConnector ( reactor = None , <EOL> dn = '<STR_LIT>' , <EOL> factory = None ) <EOL> o = c . _findOverRide ( dn = distinguishedname . DistinguishedName ( '<STR_LIT>' ) , <EOL> overrides = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> } ) <EOL> self . assertEquals ( o , ( '<STR_LIT>' , <NUM_LIT> ) ) </s>
