def testDeleteSubtree(self):
        a = inmemory.ReadOnlyInMemoryLDAPEntry(
            dn=distinguishedname.DistinguishedName('dc=example,dc=com'))
        b = inmemory.ReadOnlyInMemoryLDAPEntry(
            dn=distinguishedname.DistinguishedName('dc=example,dc=com'))

        foo=a.addChild(
            rdn='ou=foo',
            attributes={
            'objectClass': ['a', 'b'],
            'ou': ['foo'],
            })
        baz=foo.addChild(
            rdn='cn=baz',
            attributes={
            'objectClass': ['a', 'b'],
            'cn': ['baz'],
            })
        bar=a.addChild(
            rdn='cn=bar',
            attributes={
            'objectClass': ['a', 'b'],
            'cn': ['bar'],
            })

        d = a.diffTree(b)
        d.addCallback(self.assertEquals, [
            delta.DeleteOp(bar),
            delta.DeleteOp(baz),
            delta.DeleteOp(foo),
            ])
        return d
Exemple #2
0
 def testDeleteOp_DNNotFound(self):
     op = delta.DeleteOp('cn=nope,dc=example,dc=com')
     d = op.patch(self.root)
     def eb(fail):
         fail.trap(ldaperrors.LDAPNoSuchObject)
     d.addCallbacks(testutil.mustRaise, eb)
     return d
Exemple #3
0
    def testSimple(self):
        op=delta.DeleteOp('dc=example,dc=com')
        self.assertEquals(op.asLDIF(),
                          """\
dn: dc=example,dc=com
changetype: delete

""")
Exemple #4
0
    def testDelete(self):
        proto = LDIFDeltaDriver()
        proto.dataReceived("""\
version: 1
dn: cn=foo,dc=example,dc=com
changetype: delete

""")
        proto.connectionLost()
        self.assertEqual(proto.listOfCompleted,
                         [delta.DeleteOp(dn='cn=foo,dc=example,dc=com')])
Exemple #5
0
    def state_IN_DELETE(self, line):
        assert self.dn is not None, 'self.dn must be set when in entry'

        if line == '':
            # end of entry
            self.mode = ldifprotocol.WAIT_FOR_DN
            o = delta.DeleteOp(dn=self.dn)
            self.dn = None
            self.data = None
            self.gotEntry(o)
            return

        raise LDIFDeltaDeleteHasJunkAfterChangeTypeError, \
              (self.dn, line)
Exemple #6
0
 def _gotSubtree(l, result):
     l.reverse()  # remove children before their parent
     for c in l:
         o = delta.DeleteOp(c)
         result.append(o)
     return result
Exemple #7
0
 def cb3(got):
     self.assertEquals(got, [delta.DeleteOp(self.empty)])