<s> """<STR_LIT>""" <EOL> from twisted . trial import unittest <EOL> from ldaptor . protocols . ldap import ldifdelta <EOL> from ldaptor import delta , entry <EOL> class LDIFDeltaDriver ( ldifdelta . LDIFDelta ) : <EOL> def __init__ ( self ) : <EOL> self . listOfCompleted = [ ] <EOL> def gotEntry ( self , obj ) : <EOL> self . listOfCompleted . append ( obj ) <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> class TestLDIFDeltaParsing ( unittest . TestCase ) : <EOL> def testModification_empty ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( proto . listOfCompleted , <EOL> [ <EOL> delta . ModifyOp ( dn = '<STR_LIT>' ) , <EOL> ] ) <EOL> def testModification_oneAdd ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( <EOL> proto . listOfCompleted , <EOL> [ delta . ModifyOp ( dn = '<STR_LIT>' , <EOL> modifications = [ delta . Add ( '<STR_LIT:foo>' , [ '<STR_LIT:bar>' ] ) , <EOL> ] ) , <EOL> ] ) <EOL> def testModification_twoAdds ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( <EOL> proto . listOfCompleted , <EOL> [ delta . ModifyOp ( dn = '<STR_LIT>' , <EOL> modifications = [ delta . Add ( '<STR_LIT:foo>' , [ '<STR_LIT:bar>' ] ) , <EOL> delta . Add ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> ] ) , <EOL> ] ) <EOL> def testModification_complex ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( <EOL> proto . listOfCompleted , <EOL> [ delta . ModifyOp ( dn = '<STR_LIT>' , <EOL> modifications = [ delta . Delete ( '<STR_LIT:foo>' , [ '<STR_LIT:bar>' ] ) , <EOL> delta . Delete ( '<STR_LIT>' ) , <EOL> delta . Add ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> delta . Replace ( '<STR_LIT>' ) , <EOL> delta . Add ( '<STR_LIT:foo>' , [ '<STR_LIT>' ] ) , <EOL> delta . Replace ( '<STR_LIT>' , [ '<STR_LIT>' ] ) , <EOL> delta . Add ( '<STR_LIT>' ) , <EOL> ] ) , <EOL> ] ) <EOL> def testModification_fail_noDash_1 ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaModificationMissingEndDashError , <EOL> proto . dataReceived , <EOL> """<STR_LIT>""" ) <EOL> def testModification_fail_noDash_2 ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaModificationMissingEndDashError , <EOL> proto . dataReceived , <EOL> """<STR_LIT>""" ) <EOL> def testModification_fail_differentKey ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaModificationDifferentAttributeTypeError , <EOL> proto . dataReceived , <EOL> """<STR_LIT>""" ) <EOL> def testModification_fail_unknownModSpec ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaUnknownModificationError , <EOL> proto . dataReceived , <EOL> """<STR_LIT>""" ) <EOL> def testNoChangeType ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaMissingChangeTypeError , <EOL> proto . dataReceived , <EOL> """<STR_LIT>""" ) <EOL> def testAdd ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( proto . listOfCompleted , <EOL> [ delta . AddOp ( entry . BaseLDAPEntry ( <EOL> dn = '<STR_LIT>' , <EOL> attributes = { <EOL> '<STR_LIT:foo>' : [ '<STR_LIT:bar>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> } ) ) ] ) <EOL> def testAdd_fail_noAttrvals ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> self . assertRaises ( ldifdelta . LDIFDeltaAddMissingAttributesError , <EOL> proto . dataReceived , """<STR_LIT>""" ) <EOL> def testDelete ( self ) : <EOL> proto = LDIFDeltaDriver ( ) <EOL> proto . dataReceived ( """<STR_LIT>""" ) <EOL> proto . connectionLost ( ) <EOL> self . assertEqual ( proto . listOfCompleted , <EOL> [ delta . DeleteOp ( dn = '<STR_LIT>' ) ] ) </s>
