def testReplace_Delete_NonExisting(self): mod = delta.Replace('nonExisting', []) mod.patch(self.foo) self.failIf('stuff' in self.foo) self.failUnlessEqual(self.foo['sn'], ['bar']) self.failUnlessEqual(self.foo['more'], ['junk'])
def testReplace_Add(self): mod = delta.Replace('stuff', ['val1', 'val2']) mod.patch(self.foo) self.failUnlessEqual(self.foo['stuff'], ['val1', 'val2']) self.failUnlessEqual(self.foo['sn'], ['bar']) self.failUnlessEqual(self.foo['more'], ['junk'])
def testReplace_Modify(self): mod = delta.Replace('sn', ['baz']) mod.patch(self.foo) self.failIf('stuff' in self.foo) self.failUnlessEqual(self.foo['sn'], ['baz']) self.failUnlessEqual(self.foo['more'], ['junk'])
def testModify(self): op=delta.ModifyOp('cn=Paula Jensen, ou=Product Development, dc=airius, dc=com', [ delta.Add('postaladdress', ['123 Anystreet $ Sunnyvale, CA $ 94086']), delta.Delete('description'), delta.Replace('telephonenumber', ['+1 408 555 1234', '+1 408 555 5678']), delta.Delete('facsimiletelephonenumber', ['+1 408 555 9876']), ]) self.assertEquals(op.asLDIF(), """\ dn: cn=Paula Jensen,ou=Product Development,dc=airius,dc=com changetype: modify add: postaladdress postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086 - delete: description - replace: telephonenumber telephonenumber: +1 408 555 1234 telephonenumber: +1 408 555 5678 - delete: facsimiletelephonenumber facsimiletelephonenumber: +1 408 555 9876 - """)
def testReplaceAll(self): m=delta.Replace('thud') self.assertEquals(m.asLDIF(), """\ replace: thud - """)
def __setitem__(self, key, value): self._checkState() self._canRemoveAll(key) new = JournaledLDAPAttributeSet(self, key, value) super(LDAPEntryWithClient, self).__setitem__(key, new) self.journal(delta.Replace(key, value))
def testReplace(self): m=delta.Replace('foo', ['bar', 'baz']) self.assertEquals(m.asLDIF(), """\ replace: foo foo: bar foo: baz - """)
def testModification_complex(self): proto = LDIFDeltaDriver() proto.dataReceived("""\ version: 1 dn: cn=foo,dc=example,dc=com changetype: modify delete: foo foo: bar - delete: garply - add: thud thud: quux thud: baz - replace: waldo - add: foo foo: baz - replace: thud thud: xyzzy - add: silly - """) proto.connectionLost() self.assertEqual( proto.listOfCompleted, [delta.ModifyOp(dn='cn=foo,dc=example,dc=com', modifications=[delta.Delete('foo', ['bar']), delta.Delete('garply'), delta.Add('thud', ['quux', 'baz']), delta.Replace('waldo'), delta.Add('foo', ['baz']), delta.Replace('thud', ['xyzzy']), delta.Add('silly'), ]), ])